Nested Repeater Question

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?
 
S

sloan

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.
 
V

Vadivel Kumar

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top