Hi,
I am creating a dynamic columns at the run time for the infragisitcs webdatagrid. In that there are four dropdowns. On Page load, dropdown values are binding to the grid.
The main issue is as here
But when I am adding a new empty row from the viewstate, the dropdown is diplaying without binding the values.
the code is as follows
TKDataSet.V_TK_FORECASTDataTable dt = (TKDataSet.V_TK_FORECASTDataTable)ViewState["CurrentTable"]; TKDataSet.V_TK_FORECASTRow Irow = (TKDataSet.V_TK_FORECASTRow)dt.NewRow(); //Initialize the Primary Key otherwise will get error while adding new row Irow["ID"] = 0; Irow["TK_PER"] = 0; Irow["DEAL_PER"] = 0; Irow["STATUS"] = 1; Irow["EXCLUDE"] = 0; DataTable objDataTable = LoadProductsList();
HitGrid.EnableDataViewState = true;
DropDownProvider obj = new DropDownProvider(); obj.ID = "DropDownProvider1"; for (int i = 0; i < objDataTable.Rows.Count; i++) { DropDownItem objDropDownItem = new DropDownItem(objDataTable.Rows[i]["NAME"].ToString(), objDataTable.Rows[i]["VALUE"].ToString(),"",objDataTable.Rows[i]["NAME"].ToString()); obj.EditorControl.Items.Add(objDropDownItem); string a= obj.EditorControl.Items.Count.ToString(); }
obj.EditorControl.DataKeyFields = "VALUE"; obj.EditorControl.TextField = "NAME"; obj.EditorControl.ValueField = "VALUE"; obj.EditorControl.AutoSelectOnMatch = true; obj.EditorControl.BackColor = System.Drawing.Color.Red; obj.EditorControl.DataSourceID = "DropDownProvider1"; obj.EditorControl.DisplayMode = DropDownDisplayMode.DropDownList; obj.EditorControl.EnableDropDownAsChild = true; obj.EditorControl.EnableViewState = true; obj.EditorControl.ValueDisplayType = DropDownValueDisplayType.WebTextEditor; bj.EditorControl.DataBind(); string w = obj.GetEditor().ToString(); Irow["PRODUCT"] = obj; //Here in this Cell I want to bind the values which as 5 rows from the LoadProductsList but it is comming as empty dropdownlist dt.Rows.InsertAt(Irow, 0);
HitGrid.DataSource = dt; HitGrid.DataBind();
Please do the needful.
Thanks in Advance.
Hello Praveena,
I see you are setting the DataSourceID property of the dropdown editor to "DropDownProvider1", but this is the ID of the DropDownProvider, not an actual data source. You should point this to the id of the source you would like to use.
Let me know if this helps.
I'm following up to see if you need any further assistance with the matter.