Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i add "dropdownlist" values in gridview which i inserted values in gridview manually,not from database,Remember,there is no database connectivity.Here is my gridview image image
When i enter values and press "Insert" button then values inserted in gridview but when i click on edit button then in "Data Type" column shows "textbox" but i want "data type" column show "dropdownlist" which shows in blow gridview "dropdownlist".I don't want to add extra column using template field etc..

What I have tried:

here is my "Rowedit" event code aspx.cs code :
C#
protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
       {

               DataTable t = (DataTable)Session["MyDataTable"];

              GridView2.EditIndex = e.NewEditIndex;

               GridViewRow row = GridView2.Rows[e.NewEditIndex];
              // DropDownList DropDownList2 = (DropDownList)row.FindControl("DropDownList1");
               GridView2.DataSource = t;
               GridView2.DataBind();
            }
Posted
Comments
Karthik_Mahalingam 14-Apr-16 13:29pm    
you should add dropdownlist control in edit item template.
Hameed Khan 14-Apr-16 15:01pm    
No i don't want this
an0ther1 15-Apr-16 1:01am    
Why not?
When you create Template Fields you typically create three separate ones for each GridView column, an ItemTemplate (for reading), an EditItemTemplate (for editing) and a FooterItemTemplate (for adding).
This is the recommended method.


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