Datagrid & TemplateColumn

Discussion in 'ASP .Net' started by David, Oct 8, 2006.

  1. David

    David Guest

    I have the following:

    [AjaxMethod]
    public string Test()
    {
    DataSet ds = ...;
    DataGrid dg = new DataGrid();
    dg.AutoGenerateColumns = false;
    TemplateColumn tc = new TemplateColumn();
    tc.HeaderText = "Serial Number";
    tc.ItemTemplate = new TemplateColumnSN(ListItemType.Item);
    dg.Columns.Add(tc);
    dg.DataSource = ds;
    dg.DataBind();
    StringBuilder sb = new StringBuilder();
    StringWriter stWriter = new StringWriter(sb);
    HtmlTextWriter htmlWriter = new HtmlTextWriter(stWriter);
    dg.RenderControl(htmlWriter);
    return sb.ToString();
    }

    My datasource have one column named "code", I want to place an html
    button in that template column, and I want to set his value property
    with the "code" value of my datasource, I need to know how can I do
    it.
    TempalteColumnSN inherit from ITemplate and implements the
    InstantiateIn method.
    thanks.
     
    David, Oct 8, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob
    Replies:
    0
    Views:
    619
  2. =?Utf-8?B?U3RldmUgUg==?=

    Image TemplateColumn DataGrid Viewstate

    =?Utf-8?B?U3RldmUgUg==?=, Feb 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    398
    =?Utf-8?B?U3RldmUgUg==?=
    Feb 26, 2004
  3. =?Utf-8?B?U3RldmUgUg==?=

    TemplateColumn of DataGrid

    =?Utf-8?B?U3RldmUgUg==?=, Mar 1, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    442
    Brian K. Williams
    Mar 3, 2004
  4. Jade Seguin
    Replies:
    2
    Views:
    481
    Elad Volpin
    Aug 2, 2004
  5. dana lees
    Replies:
    3
    Views:
    5,055
    Eliyahu Goldin
    Sep 7, 2004
Loading...

Share This Page