moving columns in an autogenerated gridview


J

JJ297

How do I move the select button to the last column in a gridview. I
read to use the Gridview1_PreRender control and do this but I can't
get it to work:

Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles GridView1.PreRender


datacontrolfield temp = gridview1.Columns[0]
If (temp Is CommandField) Then
GridView1.Columns.RemoveAt(0)
GridView1.Columns.Insert(2, temp)
End If
End Sub

Here's my gridview:

<asp:GridView ID="GridView1" runat="server" Width="812px"
PageSize="100" DataKeyNames="TitleID"
BorderColor="#CFB37D" BorderStyle="Solid" Font-Bold="False"
Font-Names="Times New Roman"
ForeColor="Red" HorizontalAlign="Center" AllowPaging="True">

<Columns>
<asp:CommandField ShowSelectButton="True">
<ControlStyle ForeColor="Blue" />
<ItemStyle VerticalAlign="Top" />
</asp:CommandField>
</Columns>
</asp:GridView>

Any suggestions?
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top