Reputation: 334
I create in ascx page 3 GridViews, like:
<dxwgv:ASPxGridView ID="grid1" ..... >
<dxwgv:ASPxGridView ID="grid2" .... >
<dxwgv:ASPXGridView ID="grid3" ....>
</dxwgv>
</dxwgv>
</dxwgv>
But in code-behind I see only first grid (grid1) ID and can control only it. How to use others?
Upvotes: 0
Views: 2860
Reputation: 18290
A better solution is to assign unique IDs (and ClientInstanceNames), as well as scripts, to controls at runtime. This approach is described in the following Knowledge Base article: The general technique of using the Init/Load event handler.
and then another approach is that handle the ASPxGridView.DataBound event of the detail grid and get a reference to the grid via the sender parameter. Here you can call the ASPxGridView.FindDetailRowTemplateControl method of the master grid if you are using Master Details.
If you are using GridView's DataRowTemplate then use the ASPxGridView.FindRowTemplateControl Method, you just need to get the visibleIndex of the row and you are able to access the grid with it's name.
If you are using Coloumn template then use ASPxGridView.FindRowCellTemplateControl Method
protected void ASPxGridView1_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e) {
if(e.DataColumn.FieldName == "title") {
ASPxTextBox textBox = ASPxGridView1.FindRowCellTemplateControl(e.VisibleIndex, e.DataColumn, "ASPxTextBox1") as ASPxTextBox;
textBox.Text = Convert.ToString(e.CellValue);
}
}
Reference these:
ASPxGridView - How to access controls inside DetailRow on the client side
Upvotes: 0
Reputation: 100268
I think
GridView grid2 = (GridView)grid1.FindControl("grid2")
GridView grid3 = (GridView)grid2.FindControl("grid3")
should work.
Upvotes: 1
Reputation: 6149
You will not see the other gridviews since they are hidden in the first grid view, to access the other gridviews you should do the following:
grid2.RowDataBound += new EventHandler(GVsubone.RowDataBound);
P.S. you can handle any event RowDataBound was an example.
Upvotes: 0