Add your solution hereB I U S small BIG code var < > & link [^] encode untab case indent outdent Preview 0
When answering a question please:
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 Html markup:Here first we add a Gridview control, by just drag and drop on our web page. Now, will use an item template to display data .i.e (we are going to show employee name, gender, location, and department). Now we want to edit the department for the selected employees. So now we added a drop-down list under the edit template, which will display only on edit mode. Our final HTML looks like as written below. //* //*Page_load Bind gridview control:This is a simple task, we made a common function `gvBind()` which binds our Gridview control with data. On the page_load event will call this function, and now whenever the page gets load, function gvBind() gets call and data gets to display. Our final code looks as shown below. //* protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { gvBind(); } } public void gvBind() { string query="select Name,Gender,Location,department_name,department_id from myTable"; SqlDataAdapter dap = new SqlDataAdapter(query, conn); DataSet ds = new DataSet(); dap.Fill(ds); gv.DataSource = ds.Tables[0]; gv.DataBind(); } //* |