Refer : How to add Templatecolumn dynamically to DataList?
Now, instead of DataList use Repeater and make below changes
VB.NET
Public Sub BindLabelColumn(sender As Object, e As EventArgs)
Dim lbl As Label = CType(sender, Label)
Dim container As RepeaterItem = CType(lbl.NamingContainer, RepeaterItem)
Dim strVals As String = Convert.ToString(DataBinder.Eval(CType(container, RepeaterItem).DataItem, 'LastName')) + ', ' + Convert.ToString(DataBinder.Eval(CType(container, RepeaterItem).DataItem, 'FirstName'))
lbl.Text = strVals
End Sub ’BindLabelColumn
C#
public void BindLabelColumn(object sender, EventArgs e)
{
Label lbl = (Label)sender;
RepeaterItem container = (RepeaterItem)lbl.NamingContainer ;
String strVals =Convert.ToString(DataBinder.Eval(((RepeaterItem)container).DataItem, 'LastName'))
+ ', ' +
Convert.ToString(DataBinder.Eval(((RepeaterItem)container).DataItem, 'FirstName')) ;
lbl.Text = strVals;
}
Share with