Finally I also found a solution to this, posting it here for reference if
anyone else ever needs to do something similar. I involves using
TemplateColumn and DataGrid to output several generated rows with presence
information.
For doing this in code, like I did, this link explains a lot of the code in
using the TemplateColumn:
http://www.superdotnet.com/Article.aspx?ArticleID=116
To get the E-mail for presence detection and name for display from the
datasource, the following example can be used (C#):
public class MyColumnTemplat e : ITemplate
{
public void InstantiateIn(C ontrol container)
{
Label name = new Label();
name.DataBindin g += new EventHandler(my DatSource_DataB inding);
container.Contr ols.Add(name);
}
public void myDatSource_Dat aBinding(object sender, EventArgs e)
{
Label name = ((Label)(sender ));
DataGridItem container = ((DataGridItem) (name.NamingCon tainer));
string email =
Convert.ToStrin g(DataBinder.Ev al((((DataGridI tem)(container) )).DataItem,
"eMail"));
}
}//End class
This is a simple example to show how this would work. Here you only see the
"name" attribute as the output. The rest would just be added just like this
is.
Notice that you need to add an event handler that gets the source to make
this work, something that ASP.NET does automatically.
"MrCrool" wrote:
Hi
I need to be able to handle the following ASP programming in pure C# code:
<asp:TemplateCo lumn HeaderText="Cus tomer Information">
<ItemTemplate >
<table border="0">
<tr>
<td align="right">< b>Name:</b></td>
<td><%# DataBinder.Eval (Container.Data Item, "name") %></td>
</tr>
<tr>
<td align="right">< b>ID number:</b></td>
<td><%# DataBinder.Eval (Container.Data Item, "customerID ") %></td>
</tr>
<tr>
<td align="right">< b>E-mail:</b></td>
<td><%# DataBinder.Eval (Container.Data Item, "email") %>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateCol umn>
I want to be able to create TemplateColumns that contain some HTML and be
able to insert multiple values from my datasource at runtime.
The reason for this is I want it to be part of a WebPart, where the DataGrid
is added through the CreateChildCont rols() method.