Change Column order in Datagrid
I am trying to move the show band button to the last column instead of the first. Can some one help me get it done. Here is the page Band Page.
The asp code looks like this:
VB Code:
<asp:datagrid
id="dgBands"
runat="server"
BorderColor="#CC9966"
BorderStyle="None"
BorderWidth="1px"
BackColor="White"
CellPadding="4">
<FooterStyle
ForeColor="#330099"
BackColor="#FFFFCC">
</FooterStyle>
<SelectedItemStyle
Font-Bold="True"
ForeColor="#663399"
BackColor="#FFCC66">
</SelectedItemStyle>
<ItemStyle
ForeColor="#330099"
BackColor="White">
</ItemStyle>
<HeaderStyle
Font-Bold="True"
ForeColor="#FFFFCC"
BackColor="#990000">
</HeaderStyle>
<PagerStyle
HorizontalAlign="Center"
ForeColor="#330099"
BackColor="#FFFFCC">
</PagerStyle>
<Columns>
<asp:ButtonColumn
Text="Show Band"
CommandName="Select"
ButtonType="LinkButton">
</asp:ButtonColumn>
</Columns>
</asp:datagrid>
Re: Change Column order in Datagrid
Where are the rest of your columns? You should place all of them in your <Columns> section, in the order you want them to appear in.
Re: Change Column order in Datagrid
The other columns are generated automatically...so any preset bound columns always appear 1st.
Turn off the property to auto generate columns based on the datasource.
Then add the columns manually to the datagrid, like you have with the one above, and arrange them how you want.
Woka
Re: Change Column order in Datagrid
So you would have something like:
Code:
<Columns>
'Main columns
<asp:BoundColumn DataField="UserID" HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="Username" HeaderText="Username"></asp:BoundColumn>
<asp:BoundColumn DataField="Password" HeaderText="Password"></asp:BoundColumn>
'Your button column
<asp:ButtonColumn Text="Show Band" CommandName="Select" ButtonType="LinkButton"></asp:ButtonColumn>
</Columns>
Woka
Re: Change Column order in Datagrid
Thanks, turning off the auto generting columns did the trick.
I didn't end up with exactly what I had in mind but this exercise was just a self challenge to move my ASP.net skills beyond the novice level to something a little more advanced.
By the way does anybody know the answer to 24, 45, 46, 47 or 73?
The project can be found here now.