Hi
I'm using webdatagrid and binding the columns dynamically. After post-back, i've lost the editor provider values.
Regards
Sam
Hello Sam,
I'm just checking if you need any further assistance with the matter.
Hi Sam,
Using your code I created a small example. Please have a look and let me know if you have any questions.
I'm creating the columns and editor providers dynamically. Below is the source code
protected void Page_Load(object sender, EventArgs e)
{
CreateColumns();
RRPDataSet _rrpDS = RRPDAL.GetProducts();
ProductsGrid.DataSource = _rrpDS.RRP_PRODUCTS;
if (!Page.IsPostBack)
ProductsGrid.DataBind();
}
private void CreateColumns()
if (!this.IsPostBack)
this.AddColumn("PROD_CODE", "Product Code");
this.AddColumn("PART_NAME", "Part Name");
private void AddColumn(string fieldName, string headerText)
BoundDataField field = new BoundDataField(true);
field.Key = "Key_" + fieldName;
field.DataFieldName = fieldName;
field.Header.Text = headerText;
DropDownProvider drpCap = new DropDownProvider();
drpCap.ID = "DropDownProvider1";
drpCap.EditorControl.DataSource = LoadDropDowns(1).DROPDOWN;
drpCap.EditorControl.DataKeyFields ="VALUE";
drpCap.EditorControl.TextField ="NAME";
drpCap.EditorControl.ValueField ="VALUE";
this.ProductsGrid.EditorProviders.Add(drpCap);
// Create a column setting to use the editor provider
EditingColumnSetting columnSetting = new EditingColumnSetting();
columnSetting.ColumnKey = "Key_PROD_CODE";
// Assign editor for column to use
columnSetting.EditorID = drpCap.ID;
// Add column setting
this.ProductsGrid.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(columnSetting);
ProductsGrid.Columns.Add(field);
-Sam
In which event do you add the editor providers? Their datasources should be set everytime the page loads.