by changing language of gridview using resource file(.resx) the layout not remains the same

659 views Asked by At

I have that GridView in the default "English" language Gridview in "English"

When I change the language using DropDownList to "Urdu" the resource file change the language to "Urdu" but the alignment of cells don't remain the same. Gridview in "Urdu"

I think because "Urdu" is the RTL Language that is why it is changing the layout. I want to preserve the layout of GridView. Thank you

Here is the code:

<asp:GridView DataKeyNames="id" Width="455px" ID="gvProducts" runat="server" AutoGenerateColumns="False" CssClass="grid" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="dsCandidate" GridLines="Horizontal" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" meta:resourcekey="gvProductsResource1">
                    <AlternatingRowStyle BackColor="#F7F7F7" />
                    <Columns>
                        <asp:BoundField DataField="id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="id" meta:resourcekey="BoundFieldResource1" />
                        <asp:BoundField DataField="name" HeaderText="Name" SortExpression="name" meta:resourcekey="BoundFieldResource2" />
                        <asp:TemplateField HeaderText="Qualification" meta:resourcekey="TemplateFieldResource1">
                            <ItemTemplate>
                                <asp:Label ID="lblQuali" runat="server" Text='<%# Eval("Q_Type") %>' meta:resourcekey="lblQualiResource1"></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddl" runat="server" DataSourceID="dsQualification" DataValueField="Q_Id" DataTextField="Q_Type" SelectedValue='<%# Bind("Q_Id") %>' meta:resourcekey="ddlResource1"></asp:DropDownList>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="address" HeaderText="Address" SortExpression="address" meta:resourcekey="BoundFieldResource3" />
                        <asp:CheckBoxField DataField="active" HeaderText="Active" SortExpression="active" meta:resourcekey="CheckBoxFieldResource1" />
                    </Columns>
                    <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                    <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                    <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                    <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                    <SortedAscendingCellStyle BackColor="#F4F4FD" />
                    <SortedAscendingHeaderStyle BackColor="#5A4C9D" />
                    <SortedDescendingCellStyle BackColor="#D8D8F0" />
                    <SortedDescendingHeaderStyle BackColor="#3E3277" />
                </asp:GridView>
1

There are 1 answers

1
AudioBubble On BEST ANSWER

You can set/align HeaderStyle-Width or ItemStyle-HorizontalAlign to your all templates of GridView.

<asp:BoundField HeaderStyle-Width="500px" ItemStyle-HorizontalAlign="Left" />

Or you can do it dynamically in RowDataBound event like:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    e.Row.Cells[0].Width = Unit.Pixel(100);
    e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left;
}