I am trying to alter the text in a asp:TextBox from a DataList with
C#
protected void DataList7_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
TextBox tb = (TextBox)e.Item.FindControl("txtActivitate");
txtActivitate.Text = "Activitate: " + tb.Text;
}
}html
Code
.......
' class="form-control form-control-sm bg-white" ReadOnly="true" />but the change is not happening to the control "txtActivitate". How it should look like?


Marius VasileRank #785 · 2.9K reputationPosted Aug 15, 2024, 4:44 AM EDT
I found the solution with
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { TextBox tb = (TextBox)e.Item.FindControl("txtActivitate"); tb.Text = "Activitate: " + tb.Text; }