Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net GridView template check box and button fields on the right instead of the left

Hi
I am using the following GridView in my ASP.net web app. The check box and button field appears on the left of my data.
How do I get it to rather appear on the right? Thanks

                <asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" Width="100%">   
            <Columns>

                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelected" runat="server"  />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Strongly Disagree" HeaderStyle-Font-Size ="Small" 
                                            ControlStyle-Font-Bold ="false" ControlStyle-Forecolor ="DarkRed" 
                                            ControlStyle-Font-Size ="Smaller">
                    <ItemTemplate>
                        <asp:Button ID="Button10" runat="server" 
                      CommandName="MyButton5" 
                      CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
                      Text="Strongly Disagree" />
                    </ItemTemplate>
                    <ControlStyle Font-Bold="False" Font-Size="Smaller" ForeColor="DarkRed" />
                    <HeaderStyle Font-Size="Small" />
                </asp:TemplateField>
            </Columns>

            <FooterStyle BackColor="White" ForeColor="#000066" />
            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
            <RowStyle ForeColor="#000066" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#007DBB" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#00547E" />

        </asp:GridView>

Open in new window

Avatar of Dorababu M
Dorababu M
Flag of India image

Have your tried
ItemStyle-HorizontalAlign="Right"

Open in new window

Avatar of Murray Brown

ASKER

Hi. Where would I put that?
 <asp:TemplateField>
            <ItemTemplate>
               <asp:CheckBox ID="chkSelected" runat="server"  />
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
        </asp:TemplateField>

Open in new window

I changed it to the following markup but still get what you see in the image below

                <asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" Width="100%">   
            <Columns>

       <asp:TemplateField>
            <ItemTemplate>
               <asp:CheckBox ID="chkSelected" runat="server"  />

            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
        </asp:TemplateField>

                <asp:TemplateField HeaderText="Strongly Disagree" HeaderStyle-Font-Size ="Small" 
                                            ControlStyle-Font-Bold ="false" ControlStyle-Forecolor ="DarkRed" 
                                            ControlStyle-Font-Size ="Smaller">
                    <ItemTemplate>
                        <asp:Button ID="Button10" runat="server" 
                      CommandName="MyButton5" 
                      CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
                      Text="Order" />
                    </ItemTemplate>
                    <ControlStyle Font-Bold="False" Font-Size="Smaller" ForeColor="DarkBlue" />
                    <HeaderStyle Font-Size="Small" />
                
                   

                </asp:TemplateField>
            </Columns>

            <FooterStyle BackColor="White" ForeColor="#000066" />
            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
            <RowStyle ForeColor="#000066" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#007DBB" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#00547E" />
           


        </asp:GridView>

Open in new window


User generated image
I think the alignment sends it to the right of the column. I need the check box to be on the right of the GridView itself
Are you using bound columns? are they auto generated?
Yes I am using bound columns
ASKER CERTIFIED SOLUTION
Avatar of Dorababu M
Dorababu M
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks