Click here to Skip to main content
14,937,188 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview. i kept dropdownlist in gridview edititemtemplate when i click on edit button it shows dropdown list. in itemtemplate label value should be showed in dropdownlist but it coming from starting. here is my code.
here i want label value should be displayed in dropdownlist when i click on edit button.

protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)
                if ((e.Row.RowState & DataControlRowState.Edit) > 0)
                    Categoriesbll cbl = new Categoriesbll();
                    DropDownList ddlist = (DropDownList)e.Row.FindControl("ddlcategoryid");
                    GridViewRow row = e.Row.DataItem as GridViewRow;
                    ddlist.DataSource = cbl.GetCategories();
                    ddlist.DataTextField = "CategoryID";
                    ddlist.DataValueField = "CategoryName";

please help me . thank you.
Updated 14-Apr-12 0:58am
Nelek 14-Apr-12 6:58am
code tags added

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900