I have a DataGrid
where i am not able to find first row of the DataGrid
on ItemDataBound
.
its working fine With other continues rows.
CS
code of ItemDataBound
is -
protected void DgrMemberList_ItemDataBound(object sender, DataGridItemEventArgs e)
{
foreach (DataGridItem item in DgrMemberList.Items)
{
HtmlAnchor aDelivery = e.Item.FindControl("aDelivery") as HtmlAnchor;
if (e.Item.Cells[2].Text.ToString() == "STK")
{
aDelivery.HRef = "CreateDownloadImageSubmit.aspx?OID=" + e.Item.Cells[0].Text;
}
else
{
aDelivery.HRef = "javascript:void(0);";
}
}
}
Please help me out with this issue. Thanks
First you don't need to use loop in DgrMemberList_ItemDataBound
. This event will be execute for every row in your grid.
protected void DgrMemberList_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Row.DataItem == null)
return;
HtmlAnchor aDelivery = e.Item.FindControl("aDelivery") as HtmlAnchor;
if (e.Item.Cells[2].Text.ToString() == "STK")
{
aDelivery.HRef = "CreateDownloadImageSubmit.aspx?OID=" + e.Item.Cells[0].Text;
}
else
{
aDelivery.HRef = "javascript:void(0);";
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.