Hi Team,
I am using web data grid in my application. In Grid, we have 3 columns. 1) Label 2) Dropdown and 3) Internal Grid,
Based on the dropdown selection, the data should change in the internal grid.
How can we add controls to internal grid dynamically?
For example: Add dropdown and text field controls to the internal grid.
Please let me know if you have any solution for this.
Regards,
Sravani
Hello Sravani,
I have been looking into your issue and I am not sure that I understand your scenario. Do you use WebDataGrid in your third column and what is the approach that you use to add the grid there? Would you please provide me with a screenshot of the mentioned design.
Thanks in advance.
Hi Elena,
Thanks for the quick response.
Please see the below sample code.
<ig:WebDataGrid ID="gvParams" runat="server" EnableDataViewState="true" AutoGenerateColumns="false"> <Columns> <ig:BoundDataField Header-Text="name" DataFieldName="name" Key="name"> </ig:BoundDataField> <ig:TemplateDataField Key="datatype"> <ItemTemplate> <ig:WebDropDown ID="ddlCustomField" DisplayMode="DropDownList" AutoPostBack="true" runat="server" Width="120px" onselectionchanged="ddlCustomField_SelectionChanged"> </ig:WebDropDown> </ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Header-Text="Properties" CssClass="WrapTextHeader" Key="Properties"> <ItemTemplate> <ig:WebDataGrid ID="gvProperties" runat="server" ShowHeader="false" EnableDataViewState="true" AutoGenerateColumns="true"> </ig:WebDataGrid> </ItemTemplate> </ig:TemplateDataField> </Columns> </ig:WebDataGrid>
We have one dropdown field in main grid. We need add controls dynamically based on selection.
For example we have A and B are the values in dropdown, if we select A then we need add dropdown control to internal grid in selected row. If we select B then we need to add textbox to that row.
If we select "B as value from dropdown" for 2nd row of main grid then that specific row(3rd column internal grid data) need to be updated. Rest of the rows of main grid needs to be remains same.
If you need more information, please let me know.
Hi Sravani,
Thank you for the snippets. I am currently working over your scenario. I will update you on my progress tomorrow.
I have been looking into your scenario and I could suggest you use the SelectionChanged event of the DropDownProvider in order to set the data source of your nested WebDataGrid:
void EditorControl_SelectionChanged(object sender, Infragistics.Web.UI.ListControls.DropDownSelectionChangedEventArgs e) { DataTable dt = Session["ds"] as DataTable; selectedRow = (int)e.NewSelection; GridRecord r = WebDataGrid1.Behaviors.Selection.SelectedRows[0]; dt.Rows[r.Index]["Item"] =(int) e.NewSelection; WebDataGrid wdg = r.Items[2].FindControl("WebDataGrid2") as WebDataGrid; wdg.DataSource = MakeTable((int)e.NewSelection, (int)e.NewSelection + 3); wdg.DataBind(); Session["ds"] = dt; WebDataGrid1.RequestFullAsyncRender();
For additional reference you can check the attached sample.
Please let me know if this helps.