Marjani,
If you want to have more control over your GridView and what it displays you should consider configuring it so that it does not auto-generate the columns for you.
You can do this by setting the AutoGenerateColumns property to False.
Once you've done this you have to manually go in set the columns you want to display.
You can do this using the Visual Studio IDE: in Design view of your page, click on the GridView, look at the Properties for the GridView, find the Columns property and click the "..." button to add Columns.
You can do this in Source View of your page (this is the method that I prefer)...find the <asp:GridView> element...make sure it's AutoGenerateColumns property is set to False, and add your columns into the <columns> section within the GridView.
For Example:
-
<asp:GridView ID="myGrid" runat="server" AutoGenerateCollumns="False">
-
<Columns>
-
<asp:BoundField DataField="abc" HeaderText="Description for ABC" />
-
<asp:BoundField DataField="lmnop" HeaderText="Description for LMNOP"
-
<asp:BoundField DataField="xyz" HeaderText="Description for XYZ" />/>
-
</Columns>
-
</asp:GridView>
Just make sure that the DataField property matches the name of the Data Field that the column is begin bound to or this wont work :)
You can also do this dynamicallyin in your C# code but I'm not going to get into that because this method is complicated.
-Frinny