Can't pass DataItem to DataRowView in custom binding script
I have an object that returns an IList that I am getting from my ObjectDataSource and binding to a Gridview. Everything works fine if I just use the standard binding, but I try to set up the binding to set properties on the linkbutton like this:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// extract the link button
LinkButton lnkViewMap = (LinkButton)e.Row.FindControl("lnkViewMap");
// grab the datarowview
System.Data.DataRowView row = (System.Data.DataRowView)e.Row.DataItem;
// set the onclientclick to fire our showMap javascript function,
// passing through the lat/longs
lnkViewMap.OnClientClick = string.Format("showMap({0}, {1}); return false;", row["Lat"], row["Long"]);
}
}
My error occurs when I find e.Row.DataItem in DataRowView. The code above is from Matt Berseth from the awful blog on Virtual Earth ... that's what I'm trying to implement here. Any ideas?
0
source to share