0
我有一个对象返回从ObjectDataSource获取并绑定到Gridview的IList。所有工作正常,如果我只是用标准的约束力,但我想定制我的结合上一个LinkButton设置属性如下:无法在自定义绑定场景中将DataItem转换为DataRowView
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"]);
}
}
我在哪里铸造e.Row.DataItem到时我的错误DataRowView的。上面的代码来自Matt Berseth关于Virtual Earth的真棒博客......这正是我想要在这里实现的。有任何想法吗?
这样做...我将DataItem转换为我的元素类型,然后使用正常表示法访问它的属性,并且它工作...谢谢! – Webjedi 2008-11-07 14:35:27