Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top