DataTable dt = new DataTable(); DataList1.DataSource = dt; DataList1.DataBind(); DataList2.DataSource = dt; DataList2.DataBind();
<asp:DataList runat="server" ID="DataList1" RepeatDirection="Vertical"> <ItemTemplate> <table width="290px"> <tr> <td align="left"><asp:CheckBox ID="chkBttn" CssClass="chck_btn" ToolTip='<%# Eval("Price")%>' Text='<%# Eval("OptionalServicesName")%>' Checked="false" runat="server" OnCheckedChanged="CheckBox_CheckedChanged" AutoPostBack="true" /></td> <td align="right" width="40px"><asp:Label ID="ExtraPrice" Text='<%# Eval("Price")%>' runat="server"></asp:Label> </td> </tr> </table> </ItemTemplate> </asp:DataList> <asp:DataList runat="server" ID="DataList2" RepeatDirection="Vertical"> <ItemTemplate> <table width="290px"> <tr> <td align="left"><asp:CheckBox ID="chkBttn" CssClass="chck_btn" ToolTip='<%# Eval("Price")%>' Text='<%# Eval("OptionalServicesName")%>' Checked="false" runat="server" OnCheckedChanged="CheckBox_CheckedChanged" AutoPostBack="true" /></td> <td align="right" width="40px"><asp:Label ID="ExtraPrice" Text='<%# Eval("Price")%>' runat="server"></asp:Label> </td> </tr> </table> </ItemTemplate> </asp:DataList>
protected void CheckBox_CheckedChanged(object sender, EventArgs e) { string OpService = ((CheckBox)sender).Text; }