I have created a DataList in asp.net –
<asp:DataList runat="server" ID="pTextBox">
<ItemTemplate>
<asp:CheckBox ID="CheckBoxPN" runat="server" Checked='false' />
<asp:TextBox ID="profileTextBox" runat="server" Text='<%# Container.DataItem.ToString() %>'></asp:TextBox>
</ItemTemplate>
</asp:DataList>
This creates checkBoxes and textBoxes based on the string values passed through from a webService.
How can I get the profileTextBox Text string value when a user clicks CheckBoxPN and populate another textBox outwith the DataList on the page with the string value??
You can use the
CheckedChangedevent of theCheckBoxand cast it’sNamingContainertoDataListItem, the you just have to useFindControlto find a different server control:By the way, this approach works with any web-databound control(
Repeater,GridView, etc.)