Populate Dropdownlist in GridView EditItem [modified]
-
Hi, I have a DropDownList in an EditItemTemplate within the GridView. Problem is I can't find the control. In the OnDataBound there is no e.Row.RowType == DataControlRowType.EditIem like in a DataGrid. And when I try to bind the DataSet in the RowEditing Event the same thing happens. EG RowEditing
protected void gvRegisters_RowEditing(object sender, GridViewEditEventArgs e)
{
this.gvRegisters.EditIndex = e.NewEditIndex;
this.SetErrorMessage("Record opened for editing", ErrorClass.Info);//It always returns Null DropDownList ddlCompany = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlCompany")); DropDownList ddlBranch = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlBranch")); DropDownList ddlDepartment = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlDepartment")); //Fills the DropdownBoxes in the EditItemTemplate FillLocationDropDowns(ddlCompany, ddlBranch, ddlDepartment); }
Got any Ideas???
modified on Thursday, September 4, 2008 2:18 AM
-
Hi, I have a DropDownList in an EditItemTemplate within the GridView. Problem is I can't find the control. In the OnDataBound there is no e.Row.RowType == DataControlRowType.EditIem like in a DataGrid. And when I try to bind the DataSet in the RowEditing Event the same thing happens. EG RowEditing
protected void gvRegisters_RowEditing(object sender, GridViewEditEventArgs e)
{
this.gvRegisters.EditIndex = e.NewEditIndex;
this.SetErrorMessage("Record opened for editing", ErrorClass.Info);//It always returns Null DropDownList ddlCompany = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlCompany")); DropDownList ddlBranch = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlBranch")); DropDownList ddlDepartment = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlDepartment")); //Fills the DropdownBoxes in the EditItemTemplate FillLocationDropDowns(ddlCompany, ddlBranch, ddlDepartment); }
Got any Ideas???
modified on Thursday, September 4, 2008 2:18 AM
HI Mention the cell name or index like this DropDownList ddlList=(DropDownList)(GridView1.Rows[e.NewEditIndex].Cells[0].FindControl(""));
R.Palanivel 10:01 4 Jan '06
-
HI Mention the cell name or index like this DropDownList ddlList=(DropDownList)(GridView1.Rows[e.NewEditIndex].Cells[0].FindControl(""));
R.Palanivel 10:01 4 Jan '06
-
try to set runat="server" property else send me you gridview's HTML code.
R.Palanivel 10:01 4 Jan '06
-
try to set runat="server" property else send me you gridview's HTML code.
R.Palanivel 10:01 4 Jan '06
-
Hi, I have a DropDownList in an EditItemTemplate within the GridView. Problem is I can't find the control. In the OnDataBound there is no e.Row.RowType == DataControlRowType.EditIem like in a DataGrid. And when I try to bind the DataSet in the RowEditing Event the same thing happens. EG RowEditing
protected void gvRegisters_RowEditing(object sender, GridViewEditEventArgs e)
{
this.gvRegisters.EditIndex = e.NewEditIndex;
this.SetErrorMessage("Record opened for editing", ErrorClass.Info);//It always returns Null DropDownList ddlCompany = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlCompany")); DropDownList ddlBranch = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlBranch")); DropDownList ddlDepartment = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlDepartment")); //Fills the DropdownBoxes in the EditItemTemplate FillLocationDropDowns(ddlCompany, ddlBranch, ddlDepartment); }
Got any Ideas???
modified on Thursday, September 4, 2008 2:18 AM
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { if((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState ==(DataControlRowState.Edit|DataControlRowState.Alternate))) { //do your stuff } } http://blogs.ipona.com/dan/archive/2008/08/05/Three-Different-Ways-To-Find-The-Currently-Edited-Row-In.aspx[^]
modified on Thursday, August 21, 2008 5:59 AM
-
Hi the problem is your drop downl list not loaded please check viewsouce. your c# code write. you have modify your Gridview HTML code. Thanks & Regards
R.Palanivel 10:01 4 Jan '06