[thelist] ASP.NET: Binding DataRows to a Repeater
Blake
haswell00 at gmail.com
Thu Apr 2 06:35:53 CDT 2009
Hi List,
I'm trying to bind an array of DataRows to a repeater. The binding
appears to work fine, however when I try to assign a value from that
row to a control I get an error:
DataBinding: 'System.Data.DataRow' does not contain a property with
the name 'Platform'.
My code to bind the data is:
rptPlatforms.DataSource =
dsGames.Tables["GamePlatform"].Select("GameId = " +
DataBinder.Eval(e.Item.DataItem, "GameId").ToString(), "Platform");
And the OnItemDataBound code for rptPlatforms looks like:
protected void rptPlatforms_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
Literal litPlatform;
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
litPlatform = (Literal)e.Item.FindControl("litPlatform");
litPlatform.Text = (string)DataBinder.Eval(e.Item.DataItem,
"GameId"); // Error occurs here
}
}
I'm obviously accessing the data incorrectly, can anyone point me in
the right direction?
Thanks,
Blake
--
Blake Haswell
http://www.blakehaswell.com/ | Twitter: @haswell00
More information about the thelist
mailing list