Datagrid & TemplateColumn

D

David

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top