Access string value in separate DataList

hildacerulean

New Member
I have one DataList with a textBox and CheckBox -\[code\]<asp:DataList runat="server" ID="pTextBox" ><ItemTemplate><asp:CheckBox ID="CheckBoxPN" runat="server" Checked='false' OnCheckedChanged="CheckBoxPN_CheckedChanged" AutoPostBack="true" /><asp:TextBox ID="profileTextBox" runat="server" Text='<%# Container.DataItem.ToString() %>'></asp:TextBox>&nbsp;</ItemTemplate></asp:DataList>\[/code\]Where the code behind -\[code\] protected void CheckBoxPN_CheckedChanged(Object sender, EventArgs e) { CheckBox chk = (CheckBox)sender; DataListItem item = (DataListItem)chk.NamingContainer; TextBox txt = (TextBox)item.FindControl("profileTextBox"); string text = txt.Text; TextBox2.Text = txt.Text; }\[/code\]This works a treat when the CheckBox and TextBox are in the same DataList.My problem being I now have two DataLists like so -\[code\]<asp:Label ID="Label3" runat="server" Text="Exclude"></asp:Label><asp:DataList runat="server" ID="excludeTextBox"><ItemTemplate><asp:TextBox ID="myTextBox" runat="server" Text='<%# Container.DataItem.ToString() %>'></asp:TextBox></ItemTemplate></asp:DataList><asp:DataList runat="server" ID="activeCheck" ><ItemTemplate><asp:Label ID="Label4" runat="server" Text="Active"></asp:Label><asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Container.DataItem.ToString().Equals("1") %>' OnCheckedChanged="CheckBox1_CheckedChanged" AutoPostBack="true" /></ItemTemplate></asp:DataList>\[/code\]I need to access the \[code\]myTextBox\[/code\] text value when I click on \[code\]CheckBox1\[/code\] where the logic goes in -\[code\]protected void CheckBox1_CheckedChanged(Object sender, EventArgs e) { // access string value in excludeTextBox }\[/code\]How can I do this?
 
Back
Top