I am trying to alter the text in a asp:TextBox from a DataList with
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
<asp:DataList ID="DataList7" runat="server" Style="width: 100%" OnItemCommand="DataList7_ItemCommand" OnCancelCommand="DataList7_CancelCommand" OnDeleteCommand="DataList7_DeleteCommand" OnItemDataBound="DataList7_ItemDataBound" DataKeyField="AID"> ....... <ItemTemplate> <div class="row no-gutters d-flex justify-content-center"> <div class="col-sm-12"> <asp:TextBox ID="txtActivitate" runat="server" Text='<%#Eval("Activitate")%>' class="form-control form-control-sm bg-white" ReadOnly="true" /> </div> </div> </ItemTemplate>
but the change is not happening to the control "txtActivitate". How it should look like?