public void fillDept() { deptTbl dept = new deptTbl(); ddlDept.DataSource = dept.getAll(); ddlDept.DataValueField = "Id"; ddlDept.DataTextField = "deptName"; ddlDept.DataBind(); }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && GridView1.EditIndex == e.Row.RowIndex) { HiddenField deptVal = (HiddenField)e.Row.FindControl("hDeptnm"); DropDownList ddl = (DropDownList)e.Row.FindControl("ddlDept"); deptTbl dept = new deptTbl(); ddl.DataSource = dept.getAll(); ddl.DataValueField = "Id"; ddl.DataTextField = "deptName"; ddl.DataBind(); ddl.SelectedValue = deptVal.Value; } }