Results 1 to 4 of 4

Thread: Add Columns to GridView Programmatically

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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()

  3. #3
    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>

  4. #4
    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.

Similar Threads

  1. Change FireFox proxy setting programmatically
    By Puloma in forum Software Development
    Replies: 4
    Last Post: 21-09-2010, 06:50 AM
  2. Replies: 2
    Last Post: 05-06-2009, 12:02 AM
  3. Programmatically add a database
    By Zool in forum Software Development
    Replies: 2
    Last Post: 19-05-2009, 09:08 PM
  4. Free SMS Server to send SMS programmatically
    By Cavan in forum Networking & Security
    Replies: 3
    Last Post: 16-05-2009, 08:23 PM
  5. asp.net gridview to pdf
    By Dietrich in forum Software Development
    Replies: 1
    Last Post: 05-02-2009, 12:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,708,768.91310 seconds with 17 queries