Monday, April 2, 2012

get value of a column on dataitembound event of datalist

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
HtmlAnchor anchorCountry = (HtmlAnchor)e.Item.FindControl("anchrCountry");
string code=DataBinder.Eval(e.Item.DataItem, "code");
if (code == "US" || code == "CA")
{
anchorCountry.HRef = "state.aspx";
}
else
{
anchorCountry.HRef = "city.aspx";
}

}

No comments:

Post a Comment