views:

1224

answers:

1

Hi I've a gridview control nested within a repeater control


the repeater control is databound on pageload and in the itemdatabound event I look for the gridview control

If e.Item.ItemType = ListItemType.Item Then Dim gvw As GridView = DirectCast(e.Item.Controls(3), GridView) gvw.DataSource = GetData() gvw.DataBind() End If

after all this happens my page is displaying the repeater controls data and data in the gridview but the problem is only alternate gridviews have data i.e. row 1, 3, 5... in repeater control has grid that is databound but rows 2, 4, 6... does not display data

markup is - just an example

<repeater>
<itemtemplate>
<table>
<tr>
<td>
<gridview />
</td>
</tr>
<tr>
<td>
<label Text='<%# Eval("some_data") %>'
</td>
</tr>
</table>
</itemtemplate>
</repeater>

again the above markup is just an example and it is complete

I think I'm doing something seriously wrong

please help me with this

Regards, TC - 17111

A: 

In your code

If e.Item.ItemType = ListItemType.Item Then Dim gvw As GridView = DirectCast(e.Item.Controls(3), GridView) gvw.DataSource = GetData() gvw.DataBind() End If

you should add an "OR" clause to check if the ItemType is an AlternateItem as well

If e.Item.ItemType = ListItemType.Item OR e.Item.ItemType = ListItemType.AlternateItem Then Dim gvw As GridView = DirectCast(e.Item.Controls(3), GridView) gvw.DataSource = GetData() gvw.DataBind() End If
Nikos Steiakakis
Thank you so much... you rockI'm really foolish to ignore the alternate item factthanks a ton
Sometimes the worst mistakes are the easiest to fix. That's why a second pair of eyes always helps! Cheers!
Nikos Steiakakis