Suppose I have a gridview with one of its columns being an itemtemplate field which itself contains a (nested) gridview with its associated sqldatasource.
I can get that to work, but if I wanted to add a SELECT statement to the nested gridview, and have the SELECT statement refer to a routine in the code-behind page, I fail. The compiler will not recognize a routine such as:
Protected Sub GridViewSearchText_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridViewSearchText.SelectedIndexChanged
If GridViewSearchText is the inner nested gridview. It does not know that the inner gridview exists, and so cannot handle events from it.
I might be able to put a button control into the nested gridview, with an 'onClientClick' event that fires some javascript, but then the JavaScript would have to do call a routine in the code-behind.
This is what I mean by a nested gridview: (in this example, GridViewSearchText is the outer gridview, and GridViewQText is the inner Gridview. If you try it out, there is simply no way to capture events from the inner gridview in such a way that you can
identify the datakey of the inner gridview row that was selected, as well as the datakey of the outergridviewrow that contains the inner gridview.
"namingcontainer" was the answer. the namingcontainer of a nested gridview is the gridviewrow, and the namingcontainer of the gridviewrow is the gridview.
Member
56 Points
100 Posts
If gridview 'B' is nested in a field in gridview 'A', how do I catch its events?
Jan 07, 2017 09:45 PM|RateFor|LINK
Suppose I have a gridview with one of its columns being an itemtemplate field which itself contains a (nested) gridview with its associated sqldatasource.
I can get that to work, but if I wanted to add a SELECT statement to the nested gridview, and have the SELECT statement refer to a routine in the code-behind page, I fail. The compiler will not recognize a routine such as:
If GridViewSearchText is the inner nested gridview. It does not know that the inner gridview exists, and so cannot handle events from it.
I might be able to put a button control into the nested gridview, with an 'onClientClick' event that fires some javascript, but then the JavaScript would have to do call a routine in the code-behind.
Is there a better way?
All-Star
52523 Points
15678 Posts
Re: If gridview 'B' is nested in a field in gridview 'A', how do I catch its events?
Jan 08, 2017 05:27 AM|oned_gk|LINK
Not sure what you mean.
The grid is the sender, the grid namingcontainer is gridviewrow of parent grid
Suwandi - Non Graduate Programmer
Member
56 Points
100 Posts
Re: If gridview 'B' is nested in a field in gridview 'A', how do I catch its events?
Jan 08, 2017 12:39 PM|RateFor|LINK
To: Oned_gk:
This is what I mean by a nested gridview: (in this example, GridViewSearchText is the outer gridview, and GridViewQText is the inner Gridview. If you try it out, there is simply no way to capture events from the inner gridview in such a way that you can identify the datakey of the inner gridview row that was selected, as well as the datakey of the outergridviewrow that contains the inner gridview.
Member
56 Points
100 Posts
Re: If gridview 'B' is nested in a field in gridview 'A', how do I catch its events?
Jan 08, 2017 07:44 PM|RateFor|LINK
"namingcontainer" was the answer. the namingcontainer of a nested gridview is the gridviewrow, and the namingcontainer of the gridviewrow is the gridview.
Thanks Oned_gk.