how to change the columns of the gridview into multilanguage

Last post 09-14-2009 10:47 PM by Abdulla.AbdelHaq. 3 replies.

Sort Posts:

  • how to change the columns of the gridview into multilanguage

    09-14-2009, 3:57 PM
    • Member
      1 point Member
    • imranwahabit
    • Member since 06-15-2009, 8:08 AM
    • Posts 20

    hello sir i am wahab,i want to know how to change the columns of the grid view into english n arabic,as i am developing a website,as my gridview is assign to sqldatasource 

    muhammad imran
  • Re: how to change the columns of the gridview into multilanguage

    09-14-2009, 5:06 PM

    Hello,

    create two column for each language, for example lets say that you have a useraccount table and contains a username column, now you need to create two columns for that, username_en and username_ar (make username_ar to nvarchar type).

    now from UI, send a flag to the stored procedure to allow him to indecate which column should he give you. like this


    CREATE PROCEDURE [dbo].[UserAccountSelectMany]
    
    	@Lang_ID tinyint -- 1 for English and 2 for Arabic
    
    
    AS
    
    
    	
    	IF @Lang_ID = 1
    		begin 
    SELECT UserID, UserName_En As [UserName]
    
    			FROM   tbl_UserAccount
    END
    
    
    	IF @Lang_ID = 2
    		begin 
    SELECT UserID, UserName_Ar As [UserName]
    
    			FROM   tbl_UserAccount
    		END




    if you notice, I am using alliance name for both username column so that it will allow you bind it to the gridview using same alliance name "UserName"  and it will work in both UI english and arabic without the need of hidding/displaying gridivew column.

    all you need is to send the @Lang_ID to the stored procedure and it will give you the proper language under same alliance name whichi is "UserName"

    Plz remember to click "Mark as Answer" if this helped you.

    Abdulla AbdelHaq    MCTS, MCPD

    - My Articles on ASP Alliance
    - My Weblogs
    - My Sessions on JorDev User Group

    "Experience is simply the name we give our mistakes"
  • Re: how to change the columns of the gridview into multilanguage

    09-14-2009, 5:33 PM
    • Member
      1 point Member
    • imranwahabit
    • Member since 06-15-2009, 8:08 AM
    • Posts 20

    salam alikom bro i am using 7 columns in the gridview and a sqldatasource from which i am generating the column names of the gridview from the database

    AdsImage Displayedimage Alternativimage expirdate status Adslocation image Alternative

    these are the seven columns of my girdview and the source code also i am sending bro wat i have to do over here

    <

     

     

     

    asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="AdsImageID" DataSourceID="SqlDataSource1" style="margin-top: 0px" >

     

    <Columns>

     

     

     

    <asp:BoundField DataField="AdsImageID" HeaderText="AdsImageID" InsertVisible="False" ReadOnly="True" SortExpression="AdsImageID" />

     

     

    <asp:BoundField DataField="Displayedimage" HeaderText="Displayedimage" SortExpression="Displayedimage" />

     

     

    <asp:BoundField DataField="Alternativeimage" HeaderText="Alternativeimage" SortExpression="Alternativeimage" />

     

     

    <asp:BoundField DataField="Expir_date" HeaderText="Expir_date" SortExpression="Expir_date" />

     

     

    <asp:TemplateField HeaderText="Status" SortExpression="Status" >

     

    <EditItemTemplate>

     

     

    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Status") %>' />

     

    </EditItemTemplate>

     

    <ItemTemplate>

     

     

    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Status") %>' ></asp:Label>

     

    </ItemTemplate>

     

    </asp:TemplateField>

     

     

    <asp:BoundField DataField="Adslocation" HeaderText="Adslocation" SortExpression="Adslocation" />

     

     

    <asp:TemplateField HeaderText="Image" SortExpression="Image" >

     

    <EditItemTemplate>

     

     

    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Image") %>' ></asp:TextBox>

     

    </EditItemTemplate>

     

    <ItemTemplate>

     

     

     

    <asp:Label ID="LblMsgforimagetemplate" runat="server" Text='<%# Bind("Image") %>' Visible="False" ></asp:Label>

     

    <br />

     

     

     

    <asp:Image ID="Image1" runat="server" Height="30px" ImageUrl='<%# Eval("displayedimage") %>' Width="30px" />

     

    </ItemTemplate>

     

    </asp:TemplateField>

     

     

    <asp:TemplateField HeaderText="Alternative" >

     

    <ItemTemplate>

     

     

     

    <asp:Image ID="Image2" runat="server" Height="30px" ImageUrl='<%# Eval("Alternativeimage") %>' Width="30px" />

     

    </ItemTemplate>

     

    </asp:TemplateField>

     

    </Columns>

     

    </asp:GridView>

    muhammad imran
  • Re: how to change the columns of the gridview into multilanguage

    09-14-2009, 10:47 PM
    Answer

    so what, same thing, select all these 7 columns from DB and use the techniuqe that I told for multiligual columns (using alliance names) and bind them to the grid.


    Plz remember to click "Mark as Answer" if this helped you.

    Abdulla AbdelHaq    MCTS, MCPD

    - My Articles on ASP Alliance
    - My Weblogs
    - My Sessions on JorDev User Group

    "Experience is simply the name we give our mistakes"
Page 1 of 1 (4 items)