Live Chat Icon For mobile
Live Chat Icon

How to add a TemplateColumn dynamically to Repeater

Platform: ASP.NET| Category: Repeater

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

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.