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.

C#
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";
                    
                    ddlist.DataBind();
                }
            }
        }

please help me . thank you.
Posted
Updated 14-Apr-12 0:58am
v2
Comments
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