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
Kavi suja
NA
298
170.7k
Checkboxlist - Add values to Database
Nov 5 2013 6:17 AM
Hi,
I have check box list in a page. I generate values for this check box list from database in pageload as follows:
CheckBoxList2.DataSource = objRegLogic.GetSPList("SP_
Allergy");
CheckBoxList2.DataTextField = "name";
CheckBoxList2.DataValueField = "pkey";
CheckBoxList2.DataBind();
I want to add these checkboxlist value in to database in a button click.I use the following code.But when debugging " if (CheckBoxList2.Items[i].
Selected == true)" this condition can't work properly. Even i checked one item it doesn't enter in to the loop
Can u please check this code,whether i did any wrong??
protected void labtestbtn_Click(object sender, EventArgs e)
{
ConsultingEntity objConsEntity = new ConsultingEntity();
PatientConsultingBLLLogic objPatConsBLL = new PatientConsultingBLLLogic();
string Pid = Request.QueryString["PID"] as string;
if (Pid == null || Pid == string.Empty)
{
Pid = ddlPatient.SelectedValue;
}
string DocID = Convert.ToString(Session["
pkey"]);
if (DocID == null || DocID == string.Empty)
{
DocID = ddldoc.SelectedValue;
}
try
{
if (Pid == "")
{
}
else
{
for (int i = 0; i < CheckBoxList2.Items.Count; i++)
{
if (CheckBoxList2.Items[i].
Selected == true)
{
string labtest = item.Value;
objConsEntity.LabTest = labtest;
objConsEntity.Doctorid = Convert.ToInt16(DocID);
objConsEntity.PatientId = Convert.ToInt16(Pid);
objPatConsBLL.
InsertPatientLapTest(
objConsEntity);
}
}
}
}
catch (Exception ex)
{
}
}
I didn't understand where is the wrong. Can anyone help me to do this?
Reply
Answers (
1
)
Clear the particular session in mvc4
visual studio setup deployment custom action