0
<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 <%# %>?

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632

1 Answers1

0

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
  • 5,420
  • 8
  • 39
  • 50
  • 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 Weitzhandler Jun 17 '09 at 11:00
  • No execuse me i am sorry i don't know h to do that i will try seraching u the solution – Ahmy Jun 17 '09 at 11:02
  • 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 Weitzhandler Jun 17 '09 at 11:09