I have an ASP.NET page with a C# code behind and i'm working a lot with gridviews to display data. I have one that displays tasks for the current date and with checkboxes that allows the user to select multiple rows. I'm looking into a way that would allow the users to select tasks in the gridview, select a date from a drop down and press a button to copy all the data from the rows and insert it back into the database but with the date selected. I know that it'll be a simple insert statement triggered by the button. But i dont know how to get the data from the rows selected in the grid view and put them in the new insert statement. Can anyone help?
Hey, check this link " http://www.encodedna.com/aspdotnet/copy-gridview-rows-to-datatable-in-aspdotnet.htm "you will get the data in this. Good Luck.
Hi, You can check this Code: protected void OnSelectedIndexChanged(object sender, EventArgs e) { //Accessing BoundField Column string name = GridView1.SelectedRow.Cells[0].Text; //Accessing TemplateField Column controls string country = (GridView1.SelectedRow.FindControl("lblCountry") as Label).Text; lblValues.Text = "<b>Name:</b> " + name + " <b>Country:</b> " + country; } Thanks