Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1140
Reg: WebDropDown loading fail when new row is added
posted

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.