Click here to Skip to main content
15,921,210 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is it possible to have a datagrid with database without an autogeneratedcolumns
Posted
Comments
Ankur\m/ 5-May-11 1:35am    
yes. set autogeneratecolumns property to false. And bind it to a datasource (such as binding source or datatable etc)

//set AutoGenerateColumns = False as Below
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"> 


//try to find out in this way 

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True"
                       OnPageIndexChanging="GridView1_PageIndexChanging" PageSize="2" >
                       <Columns>
                           <asp:TemplateField>
                           <asp:CommandField HeaderText="Edit" ShowEditButton="True" />
                           <asp:BoundField HeaderText="ProdId" DataField="ProductId"  />
                           <asp:BoundField HeaderText="ProdName" DataField="ProductName" />
                           <asp:BoundField HeaderText="ProdPrice" DataField="ProductPrice"  />
                           </asp:TemplateField>
                       </Columns>
                   </asp:GridView>
// DataField="ProductId" this (ProductId) should be same as your DataBase Column Name or Porperties if you Have Used tht.
 
Share this answer
 
v3
Comments
janwel 5-May-11 1:38am    
sir when i make the autogeneratecolumm into false the data from database will not be sored in the gridview

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900