Nested Repeater Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a nested repeater and this is the code I have in the item data bound
event

private void _repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem rItem = e.Item;
DataRowView drv = (DataRowView) rItem.DataItem;
..........
.........
But when I complile I get an error that specified case is not valid (for
DataRowView).

Any help?
 
if you do it ... the other way... does it crap on you?

DataRowView drv = rItem.DataItem as DataRowView;
if(null!=drv)
{
//it actually was a DataRowView item.
}

I"m not sure on a repeater, but isnt there a e.RowType or something? (im
thinking of a GridView, where there is HeaderRow(type) and ItemRowType.

...

I'm going from memory... so don't put too much hope in my post.
 
The casting you are doing is based on the DataSource you have assigned
to the Repeater control.

In case of a DataTable is assigned to the Repeater.DataSource then you
can write a code similar like below,

private void _repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{

RepeaterItem rItem = e.Item;
DataRow drv = (DataRow) rItem.DataItem;
...
}

If this doesn't help, put a debug mark inside this method and check the
type of "rItem.DataItem" using "Immediate Window" or "Quick Watch"
window. You can even see the data present in the DataItem object. Based
on that cast the "rItem.DataItem", It should work.

-
Vadivel Kumar
http://vadivelk.net
 
Back
Top