Add Columns to GridView Programmatically
I can add template field but i am facing the problem while capturing events of the template. I am trying to add template field to an ASP.NET GridView control using C# programmatically. I had column with template which contain check box. The javascript is activated on the row when i click on that check box. Is their another way to do this by danamic method. Any recommendations and suggestions are appreciated.
Re: Add Columns to GridView Programmatically
Code:
GridView1.AutoGenerateColumns = False
Dim Field As New BoundField
Field.DataField = "UID"
Field.HeaderText = "User ID"
Dim Col As DataControlField = Field
GridView1.Columns.Add(Column)
Field = New BoundField
Field.DataField = "UROLLNO"
Field.HeaderText = "User Roll No"
Col = Field
GridView1.Columns.Add(Column)
Field = New BoundField
Field.DataField = "UDATA"
Field.HeaderText = "User Data Information"
Col = Field
GridView1.Columns.Add(Column)
GridView1.DataBind()
Re: Add Columns to GridView Programmatically
I added progrmmaticaly a templateField into GridView. In ASP.Net 2.0 we have a DataView “SORT” property that solves this problem easily and effectively.
Code:
<div>
<asp:GridView ROLL NO="GridView1" runat="server">
</asp:GridView>
</div>
Re: Add Columns to GridView Programmatically
I have this code in the aspx file of a GridView control:
Code:
<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox ID="chkNotifierAdd" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
I need to add the TemplateField, ItemTemplate, and Checkbox controls.