Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. a problem on dynamic datagrid

a problem on dynamic datagrid

Scheduled Pinned Locked Moved C#
designdockerhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Siva Myneni
    wrote on last edited by
    #1

    Hi all, I have added linkbutton to the datagrid in the template column.i have to display particular field of datasource to the lnkbutton text.My code is like this this is a class file public class DataGridTempla :System.Web.UI.Page,ITemplate { ListItemType templateType; string columnName; public DataGridTempla( ListItemType type,string colname) { templateType = type; columnName = colname; } public void InstantiateIn(System.Web.UI.Control container) { Literal lc = new Literal(); LinkButton lb = new LinkButton(); lb.Click+=new EventHandler(lb_Click); case ListItemType.Item: lc.Text=columnName; lc.Text = "Select " + columnName; lb.CommandName = "EditButton"; lb.Text= "" + columnName + ""; //container.Controls.Add(chkb); container.Controls.Add(lb); container.Controls.Add(lc); } this is my webform coding TemplateColumn tc=new TemplateColumn(); tc.ItemTemplate=new DataGridTempla(ListItemType.Item,"BrandId" ); BoundColumn bc=new BoundColumn(); bc.DataField="Brand_Name"; DataGrid1.Columns.AddAt(0,tc); DataGrid1.Columns.AddAt(1,bc); DataGrid1.DataBind(); please try this.

    sivamyneni

    N 1 Reply Last reply
    0
    • S Siva Myneni

      Hi all, I have added linkbutton to the datagrid in the template column.i have to display particular field of datasource to the lnkbutton text.My code is like this this is a class file public class DataGridTempla :System.Web.UI.Page,ITemplate { ListItemType templateType; string columnName; public DataGridTempla( ListItemType type,string colname) { templateType = type; columnName = colname; } public void InstantiateIn(System.Web.UI.Control container) { Literal lc = new Literal(); LinkButton lb = new LinkButton(); lb.Click+=new EventHandler(lb_Click); case ListItemType.Item: lc.Text=columnName; lc.Text = "Select " + columnName; lb.CommandName = "EditButton"; lb.Text= "" + columnName + ""; //container.Controls.Add(chkb); container.Controls.Add(lb); container.Controls.Add(lc); } this is my webform coding TemplateColumn tc=new TemplateColumn(); tc.ItemTemplate=new DataGridTempla(ListItemType.Item,"BrandId" ); BoundColumn bc=new BoundColumn(); bc.DataField="Brand_Name"; DataGrid1.Columns.AddAt(0,tc); DataGrid1.Columns.AddAt(1,bc); DataGrid1.DataBind(); please try this.

      sivamyneni

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Siva Myneni wrote:

      please try this.

      Ok, I tried it, now what? First, as this is related to ASP.NET you might get a better response by posting it to that forum. Second, try using a template in the the aspx rather creating it in the code-behind

      only two letters away from being an asset

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups