Hi,
I am inserting data into db using checkboxlist using following code, but while updating form I am not able to bind the checkboxlist. Please solve my problem.
------------ Design--------
<tr>
<td class="td_Subhead" width="345px" > Select Districts </td>
<td class="td_Subhead" width="650px">
<div>
<asp:UpdatePanel ID="updatepanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" autocomplete="off" Text ="" onFocus="javascript:this.blur();"></asp:TextBox>
<asp:PopupControlExtender
ID="TextBox1_PopupControlExtender" runat="server"
Enabled="True" ExtenderControlID=""
TargetControlID="TextBox1"
PopupControlID="Panel1" OffsetY="800" OffsetX ="20">
</asp:PopupControlExtender>
<asp:Panel ID="Panel1" runat="server"
Height="116px" Width="145px"
BorderStyle="Solid" BorderWidth="2px"
Direction="LeftToRight"
ScrollBars="Auto" BackColor="#CCCCCC"
Style="display: none">
<asp:CheckBoxList ID="CheckBoxList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="district_name"
DataValueField="district_id" AutoPostBack="True"
OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged">
</asp:CheckBoxList>
<asp:SqlDataSource ID="SqlDataSource1"
runat="server" ConnectionString="<%$
ConnectionStrings:PsaConnection %>"
SelectCommand="SELECT * FROM [tbl_district]">
</asp:SqlDataSource>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</td>
</tr>
------END-----
string value = "";
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
value += CheckBoxList1.Items[i].Value + ",";
}
}
string actualid = "";
string[] strArray;
strArray = value.Split(@",".ToCharArray());
foreach (string di in strArray)
{
if (di == "" || di == null)
{
break;
}
actualid = di;
bool result = Queries.Que_Add_Psa_Lic_Details_mul(Lic_deatils_id, di, Lic_deatils_id);
}
Thanks,
Gayatri P