Datalist With multiple Datakeys
How to add Multiple datakeys to datalist in asp.net c#
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.
Sanjeeb LenkaPosted Jul 4, 2013, 7:57 AM
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;
}
}
}
Iftikar HussainPosted Jul 4, 2013, 6:52 AM
You can do this by like below
Regards,
Iftikar