I have table with 4 fields pkey,name,whosinfo_pkey,description.Here 'pkey' is autogenerated key. The sample values following here:
'75', 'Contact Dermatitis', '513', 'Contact Dermatitis'
'76', 'Anaphylaxis', '513', 'Anaphylaxis'
'77', 'Insect Venom', '513', 'Insect Venom'
'78', 'Atopic Dermatitis', '520', 'Atopic Dermatitis'
'79', 'Food Alergies', '520', 'Food Alergies'
'80', 'Insect Venom', '520', 'Insect Venom'
CREATE DEFINER=`root`@`%` PROCEDURE `SPUpdateMA`(in pkey varchar(45),
in DisName varchar(60)
)
BEGIN
UPDATE medicalhistory medhis
INNER JOIN whosinfo whos
ON whos.pkey=medhis.whosInfo_pkey
SET
medhis.name=DisName,
/*medhis.whosInfo_pkey=pkey,*/
medhis.description=DisName
WHERE medhis.whosInfo_pkey=pkey;
END
In update button click I use following code:try
{
if (whospkey == "")
{
}
else
{
//string patid = Request.QueryString["Ptid"];
for (int i = 0; i < CheckBoxList2.Items.Count; i++)
{
if (CheckBoxList2.Items[i].Selected == true)
{
objReg.Name = CheckBoxList2.Items[i].Text;
objReg.WhosInfo = whospkey;
// objReg.WhosInfo = Convert.ToString(ViewState["WhosInfo"]);
objRegLogic.UpdatePMedHis(objReg);
}
}
}
}
catch (Exception ex)
{
}
In design page,I use checkboxlist as following:
CssClass="CheckboxList" Width="100%" RepeatDirection="Horizontal" BorderColor="#3399FF">
Here the problem is,when I update this it will update all data like following:
'75', 'Contact Dermatitis', '513', 'Contact Dermatitis'
'76', 'Anaphylaxis', '513', 'Anaphylaxis'
'77', 'Insect Venom', '513', 'Insect Venom'
'78', 'Anaphylaxis', '520', 'Anaphylaxis'
'79', 'Anaphylaxis', '520', 'Anaphylaxis'
'80', 'Anaphylaxis', '520', 'Anaphylaxis'
But actually I check 3 checkboxes.It takes last checkbox value only Hives,Food Allergies,Anaphylaxis.How I overcome this?How can I update values here correctly?Can anyone help me?
5 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Iftikar HussainPosted Aug 2, 2013, 8:20 AM
Regards,
Iftikar
Kavi sujaPosted Aug 2, 2013, 8:17 AM
Can you explain it?I can't understand.
Iftikar HussainPosted Aug 2, 2013, 8:10 AM
Regards,
Iftikar
Kavi sujaPosted Aug 2, 2013, 7:40 AM
I read whospkey value from whosinfo table using stored procedure "SPEditPatient".The code is following:
}
Iftikar HussainPosted Aug 2, 2013, 7:33 AM
How you are reading whospkey value? can you share that?
Regards,
Iftikar