TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gayatri Pattar
NA
25
75.4k
How to fetch data based on selected checkboxlist from db?
Jan 4 2014 12:59 AM
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
Reply
Answers (
0
)
Doubt for MVC
How copy data from open office excel and paste in listview