How do you bind columns manually in datagrid ?

Questions by sreeneela

Showing Answers 1 - 0 of 0 Answers

<asp:Gridview id="gvTest" runat="server" autogeneratacolumns="false">
<columns>
<itembound>
...
</itembound>
</columns>
</asp:gridview>

Using this we can bind the columns manually.

  Was this answer useful?  Yes

To bind Columns manually in grid view you have to used <asp:BoundFiled>under columns list, set columns name as value to "DataFiled" attribute of <asp:BoundFiled> tag

For example

<asp:GridView ID="gridview1" AutoGenerateColumns="false" runat="server">
            <Columns>
                <asp:BoundField DataField="[Columnname]" .... />
            </Columns>
 </asp:GridView>

kumaran04u

  • Aug 26th, 2010
 

<asp:Gridview id="Gvsample" runat="server" autogeneratedcolumns="false" datakeynames="This is your primary keyid" allowpaging="true" pagesize="5">

<column>
<asp:templatefield headertext="Name">
<itemtemplate>
<asp:label id="lblname" runat="server" text='<% #bnd("Name")>'/>
</itemtemplate>
</asp:templatefield>
</column>


This is the way to bind the data in your gridview control

  Was this answer useful?  Yes

lata negi

  • Nov 4th, 2011
 

Code
  1. asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" AutoGenerateColumns="False"

  2. runat="server">

  3.  

  4. <Columns>

  5. <asp:BoundField HeaderText="ID" DataField="au_id" ReadOnly="true"/>

  6.  

  7. <asp:BoundField HeaderText="Last Name" DataField="au_lname"/>

  8.  

  9. <asp:BoundField HeaderText="First Name" DataField="au_fname"/>

  10.  

  11. <asp:BoundField HeaderText="Phone" DataField="phone"/>

  12.  

  13. <asp:BoundField HeaderText="Address" DataField="address"/>

  14. </Columns>

  15.  

  16. </asp:GridView>

  17.  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions