I've got a simple webhierarrchicaldatagrid and I'm trying to add columns dynamically to it after a dropdownlist is selected. No matter what I do I can only add columns to the grid from the initial page load. Is it possible to do this or is there a re-render I need to call after adding the columns?
Thanks
Additional question, I'm adding a dropdownprovider on one of the dynamically added columns but it doesn't seem to be doing anything, do you see anything that sticks out?
var wddProvider = new DropDownProvider() { ID = "wdd" + col.Key }; wddProvider.EditorControl.DataSource = selectionValues; wddProvider.EditorControl.DataBind(); wddProvider.EditorControl.DataKeyFields = "SelectionValue"; wddProvider.EditorControl.ValueField = "SelectionValue"; wddProvider.EditorControl.TextField = "SelectionValue"; wddProvider.EditorControl.DisplayMode = DropDownDisplayMode.DropDownList; grdTestResults.EditorProviders.Add(wddProvider);
grdTestResults.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(new EditingColumnSetting(grdTestResults.GridView) { ColumnKey = col.Key, EditorID = wddProvider.ID });
I think I figured this out. I've got the page load
if (Session["data"] != null) { grdTestResults.DataSource = (DataSet)Session["data"]; grdTestResults.DataBind(); }
Then in the row updating I'm doing my updates then re-querying the data then doing a clear datasource and reseting.
grdTestResults.GridView.ClearDataSource(); grdTestResults.DataSource = (DataSet)Session["data"]; grdTestResults.DataBind();
Is this the preferred way to do this?
Separate question; I've got a NumericEditorProvider I can't get it to postback on value change when the cell is left through either the RowUpdating or the OnValuechanged event.
<ig:NumericEditorProvider ID="grdTestResults_NumericEditorProvider1"> <EditorControl ClientIDMode="Predictable" DataMode="Decimal" OnValueChanged="OnValueChanged"> <AutoPostBackFlags ValueChanged="On" /> </EditorControl> </ig:NumericEditorProvider>
Thanks again
Here's a link to download it https://www.dropbox.com/s/1l9ap3e6h3sw72k/MeteorQualityDBCopy.zip?dl=0
If you need the DB let me know
Hello Anthony,
can you please send me the whole project with the code behind, so that I will be able to investigate the problem with the Manual CRUD?
Yana, got a follow up question which should hopefully be simple. I'm using manual crud and trying to updating after each cell change. I've got that pretty much working except when the the RowUpdating event fires and I do my manual updates the grids datasource is being set in the page load with the dataset (like your example has it) and then the grid displays the old info.
Any thoughts or better ways to do this?
<ig:WebHierarchicalDataGrid ID="grdTestResults" runat="server" Height="350px" Width="100%" DataKeyFields="ID" DataMember="Parent" Key="Parent" AutoGenerateBands="False" EnableViewState="False" OnRowUpdating="grdTestResults_OnRowUpdating" AutoGenerateColumns="False"> <Columns> <ig:BoundDataField DataFieldName="TestDateTime" DataFormatString="{0:M/d/yyyy h:mm tt}" DataType="System.DateTime" Key="TestDateTime"> <Header Text="Test Date/Time"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Tech" Key="Tech"> <Header Text="Tech"></Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="LotNumber" Key="LotNumber"> <Header Text="Lot No"></Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Line" Key="Line"> <Header Text="Line"></Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="PartNumber" Key="PartNumber"> <Header Text="Part No"></Header> </ig:BoundDataField> </Columns> <AjaxIndicator Enabled="True" /> <Bands> <ig:Band DataMember="Child" Key="Child" AutoGenerateColumns="False"> <Columns> <ig:BoundDataField DataFieldName="TestDateTime" DataFormatString="{0:M/d/yyyy h:mm tt}" DataType="System.DateTime" Key="TestDateTime"> <Header Text="Test Date/Time"> </Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Tech" Key="Tech"> <Header Text="Tech"></Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="LotNumber" Key="LotNumber"> <Header Text="Lot No"></Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Line" Key="Line"> <Header Text="Line"></Header> </ig:BoundDataField> <ig:BoundDataField DataFieldName="PartNumber" Key="PartNumber"> <Header Text="Part No"></Header> </ig:BoundDataField> </Columns> </ig:Band> </Bands> <Behaviors> <ig:Activation> <ActivationClientEvents ActiveCellChanged="grdTestResults_Activation_ActiveCellChanged" /> </ig:Activation> <ig:EditingCore AutoCRUD="False"> <Behaviors> <ig:CellEditing> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="TestDateTime" EditorID="e_DateTimePicker" /> </ColumnSettings> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> <EditorProviders> <ig:DatePickerProvider ID="e_DateTimePicker"> <EditorControl runat="server" DisplayModeFormat="g" EditModeFormat="g" DropDownCalendarID="WebMonthCalendar1" EnableAjaxViewState="False"> <AutoPostBackFlags ValueChanged="On" /> </EditorControl> </ig:DatePickerProvider> </EditorProviders> </ig:WebHierarchicalDataGrid>