Why doesn't the casting of "e.Item.DataI*tem" as a "DataRow" (or even
a "DataRowView" as in other online examples) work? I would love to get
this type of code to work with my code that uses a Label for building a
URL instead of the RadioButtonList as in the example snippet below. I
know how to implement this with a Label but I end up having to do
something like this:
myLabel.Text = (string) DataBinder.Eval(e.Item.DataItem, "Info");
instead of something much cleaner, logical looking, and desirable (to
me) like this:
myLabel.Text = (string) ((DataRow)e.Item.DataI*tem)["Info"];
Also, the thought of "DataBinder.Eval" just seems to partially negate
moving this to the codebehind.
-
Here is an example snippet from this newsgroup that I found that
doesn't work either...and it give the same "cast" error on casting as
"DataRow".
<asp:repeater id="rptEstimates" runat="server"
ItemDataBound="DataBoundItem>
....
<script runat="server">
void DataBoundItem(Object Sender, RepeaterItemEventArgs e) {
// This event is raised for the header, the footer,
separators,
and items.
// Execute the following logic for Items and Alternating
Items.
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType
==
ListItemType.AlternatingItem) {
RadioButtonList rbl =
(RadioButtonList)e.Item.FindCo*ntrol("rptEstimates ");
if ( rbl != null )
{
rbl.SelectedValue =
(string)((DataRow)e.Item.DataI*tem)["BidResponse"];
}
}
}
-
Is there a problem with Framework version maybe?