views:

765

answers:

1
<asp:GridView DataSource="Reports">
    <ItemTemplate>
        <asp:TextBox Text='<%# Bind("ReportId") %>'
        <asp:Repeater DataSource="Something that is different than the GridView's DS">
            <a href='<%# Bind("ReportId", "reports.aspx?report={0}") %>'/>
        </asp:Repeater>
    </ItemTemplate>
</asp:GridView>

I know this is inachievable, I am looking for a way to use ReportId from the parent gridview in the nested repeater, is there a way to do it with server side code <%# %>?

A: 

Set the gridview

DataKeyField="ReportId"

and in the event GridView1_ItemDataBound inside it

protected void GridView1_ItemDataBound(object sender, GridViewItemEventArgs e)    
((TextBox)e.Item.FindControl("TextBox1")).text = GridView1.DataKeys[0].ToString();

and in this case u set the textbox with the value of the ID, try it and hope that it will be usefull.

Ahmy
As I specified, I am looking for a way to do it with <%# %>.meanwhile i do it in the code by handling the Repeater's row databound event cehecking if current row is the Footer which works even better.
Shimmy
No execuse me i am sorry i don't know h to do that i will try seraching u the solution
Ahmy
Thanks for your help, I realized that it doesn't have to be in the repeater, I put it outside the repeater and that's it.But I will still have such issues in future.
Shimmy