Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 19-05-2009
Member
 
Join Date: Apr 2009
Posts: 47
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.
Reply With Quote
  #2  
Old 19-05-2009
Member
 
Join Date: May 2008
Posts: 2,008
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()
Reply With Quote
  #3  
Old 19-05-2009
Member
 
Join Date: Jan 2009
Posts: 199
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>
Reply With Quote
  #4  
Old 19-05-2009
Member
 
Join Date: Apr 2009
Posts: 47
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Add Columns to GridView Programmatically"
Thread Thread Starter Forum Replies Last Post
Change FireFox proxy setting programmatically Puloma Software Development 4 21-09-2010 06:50 AM
asp.net adding databound hyperlink columns to gridview programmatically Amitesh Software Development 2 05-06-2009 12:02 AM
Programmatically add a database Zool Software Development 2 19-05-2009 09:08 PM
Free SMS Server to send SMS programmatically Cavan Networking & Security 3 16-05-2009 08:23 PM
asp.net gridview to pdf Dietrich Software Development 1 05-02-2009 12:15 PM


All times are GMT +5.5. The time now is 10:23 PM.