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

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...