i have gridview with 5 colomns c1,c2,c3,c4,c5 here i want to add a dropdownlist only c1 and c2 what is the procedure for do this work
here i am using the code like this but it produce error pls anybody correct that error
error: object reference not set to an instance of an object
code is:
conn.Open();
DataSet ds = new DataSet();
SqlCommand cmp = new SqlCommand("SELECT * from Projectcodetable ", conn);
SqlDataAdapter dr = new SqlDataAdapter(cmp);
dr.Fill(ds);
DropDownList list = (DropDownList)e.Row.FindControl("DropDownList1");
error line ==> list.DataSource = ds; // object reference not set to an instance of an object//
list.DataValueField = "ProjectCode";
list.DataTextField = "ProjectCode";
list.DataBind();
conn.Close();
thanks
note: vs2008,asp.net with c#