Datalist With multiple Datakeys
How to add Multiple datakeys to datalist in asp.net c#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 4, 2013, 2:52 AM EDT
You can do this by like below
Regards,
Iftikar
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 4, 2013, 3:57 AM EDT
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable tbl = new DataTable();
tbl.Columns.Add("MessageId", typeof(Int32));
tbl.Columns.Add("UserId", typeof(Int32));
tbl.Rows.Add(1, 100);
tbl.Rows.Add(2, 200);
DLMessages.DataSource = tbl;
DLMessages.DataBind();
}
for (int i = 0; i < DLMessages.Items.Count; i++)
{
if (((CheckBox)DLMessages.Items[i].FindControl("ChkBxMsg")).Checked == true)
{
int userid = int.Parse(((DataBoundLiteralControl)((Label)DLMessages.Items[i].FindControl("lbluserId")).Controls[0]).Text);
Response.Write(userid);
break;
}
}
}