Sunday, August 11, 2013

Bind DropDownList in Edit Footer And Empty templates


 if (e.Row.RowType == DataControlRowType.DataRow && gridCategory.EditIndex ==e.Row.RowIndex)
        {
            string MenuName = ((HiddenField)e.Row.FindControl("hiddenMenuName")).Value;
            DropDownList ddlMenu = (DropDownList)e.Row.FindControl("ddlMenu");
            bindddMenu(ddlMenu, MenuName);
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            DropDownList ddlMenu = (DropDownList)e.Row.FindControl("ddlMenu");
            bindddMenu(ddlMenu, "");
        }
        else if (e.Row.RowType == DataControlRowType.EmptyDataRow)
        {
            DropDownList ddlMenu = (DropDownList)e.Row.Controls[0].Controls[0].FindControl("ddlMenu");
            bindddMenu(ddlMenu, "");
        }

OR


    protected void gridCategory_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.EmptyDataRow)
        {
            DropDownList ddlMenu = (DropDownList)e.Row.FindControl("ddlMenu");
            bindddMenu(ddlMenu, "");
        }
    }



No comments:

Post a Comment