My gridview is being generated at runtime by a dataset. My first column is a template field with checkbox, how to delete a selected row? C# please.
AngelicOne
4
Posting Whiz
Recommended Answers
Jump to PostDo you want the row to be deleted, as soon as the checkbox is clicked, or do you have a delete button and when that button is clicked you want to delete all the rows that have their checkbox clicked?
Jump to Postok you have checkbox as TemplateField and it's in the first column.
add a button outside the grid.
on button click iterate through the gridview rows and
find checkbox control and check it's checked propertyand see if it is checked and if yes then delete the …
Jump to PostI believe Your code is looking correct. I guess if you change your current line with below one than it should be work..
string id = GridView1.DataKeys[row.RowIndex].Value.ToString();
Let us know if it's not working..
could you give a sample code?
this is my current code but it's not …
Jump to PostIt should have to work.. one thing can you please make sure whether you have set the DataKeyNames property or not in GridView tag ? If not than you need to set it with "Register_ID " your key column.
protected void DeleteSelected_Click(object sender, EventArgs e) { //iterate …
Jump to PostSure... It's used to Get or set an array that contains the names of the primary key fields for the items displayed in a GridView control.
It's very helpfull at the time of Updating or Deleting data from database through the gridview control.
So just make sure you …
All 20 Replies
plusplus
0
Posting Whiz in Training
dnanetwork
18
Practically a Master Poster
Banned
AngelicOne
4
Posting Whiz
rohand
1
Posting Whiz in Training
AngelicOne
4
Posting Whiz
rohand
1
Posting Whiz in Training
AngelicOne
4
Posting Whiz
rohand
1
Posting Whiz in Training
AngelicOne
4
Posting Whiz
rohand
1
Posting Whiz in Training
AngelicOne
4
Posting Whiz
rohand
1
Posting Whiz in Training
AngelicOne
4
Posting Whiz
AngelicOne
4
Posting Whiz
rohand
1
Posting Whiz in Training
AngelicOne
4
Posting Whiz
rohand
1
Posting Whiz in Training
AngelicOne
4
Posting Whiz
AngelicOne
4
Posting Whiz
rohand
1
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.