Solved

Put ASP.net GridView template columns on right instead of left

Posted on 2014-01-04
4
538 Views
Last Modified: 2014-01-06
Hi

I have the following  ASP.net GridView with 5 template columns on the left. How do I change the columns to rather appear on the right

<asp:GridView ID="GridView_Questions" runat="server" BackColor="White"
                BorderColor="#3366CC" BorderStyle="Solid" BorderWidth="1px" CellPadding="4"
                Height="147px" Visible="False" Width="795px">
                <Columns>

                      <asp:TemplateField HeaderText="Strongly Agree" HeaderStyle-Font-Size ="Small"
                                            ControlStyle-Font-Bold ="false" ControlStyle-Forecolor ="#006600"
                                            ControlStyle-Font-Size ="Smaller">
                    <ItemTemplate>
                        <asp:Button ID="Button6" runat="server"
                      CommandName="MyButton1"
                      CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
                      Text="Strongly Agree" />
                    </ItemTemplate>
                    <ControlStyle Font-Bold="False" Font-Size="Smaller" ForeColor="#006600" />
                    <HeaderStyle Font-Size="Small" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Agree" HeaderStyle-Font-Size ="Small" ControlStyle-Font-Bold ="false"
                                            ControlStyle-Forecolor ="#009900"
                    ControlStyle-Font-Size ="Smaller">
                    <ItemTemplate>
                        <asp:Button ID="Button7" runat="server"
                      CommandName="MyButton2"
                      CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
                      Text="Agree" />
                    </ItemTemplate>
                    <ControlStyle Font-Bold="False" Font-Size="Smaller" ForeColor="#009900" />
                    <HeaderStyle Font-Size="Small" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Undecided" HeaderStyle-Font-Size ="Small"
                                            ControlStyle-Font-Bold ="false" ControlStyle-Forecolor ="SlateGray"
                                            ControlStyle-Font-Size ="Smaller">
                    <ItemTemplate>
                        <asp:Button ID="Button8" runat="server"
                      CommandName="MyButton3"
                      CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
                      Text="Undecided" />
                    </ItemTemplate>
                    <ControlStyle Font-Bold="False" Font-Size="Smaller" ForeColor="SlateGray" />
                    <HeaderStyle Font-Size="Small" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Disagree" HeaderStyle-Font-Size ="Small"
                                            ControlStyle-Font-Bold ="false" ControlStyle-Forecolor ="#FF6600"
                                            ControlStyle-Font-Size ="Smaller">
                    <ItemTemplate>
                        <asp:Button ID="Button9" runat="server"
                      CommandName="MyButton4"
                      CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
                      Text="Disagree" />
                    </ItemTemplate>
                    <ControlStyle Font-Bold="False" Font-Size="Smaller" ForeColor="#FF6600" />
                    <HeaderStyle Font-Size="Small" />
                </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="#99CCCC" ForeColor="#003399" />
                <HeaderStyle BackColor="White" Font-Bold="False" ForeColor="#000066" />
                <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                <RowStyle BackColor="White" ForeColor="#003399" />
                <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                <SortedAscendingCellStyle BackColor="#EDF6F6" />
                <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                <SortedDescendingCellStyle BackColor="#D6DFDF" />
                <SortedDescendingHeaderStyle BackColor="#002876" />
            </asp:GridView>
0
Comment
Question by:murbro
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39756364
Do you mean you want to show the grid on the right hand side in its container control?
0
 

Author Comment

by:murbro
ID: 39756532
I want the Grid to be on the left and the template columns on the right
0
 
LVL 14

Accepted Solution

by:
dejaanbu earned 500 total points
ID: 39756906
There should be a horizontal align property for the template column. Set it to right.
0
 

Author Closing Comment

by:murbro
ID: 39758831
Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now