Hi there,
Am trying to get an entire row of my datagridview selected, because one of its columns contains a value similar to a value in my textbox1.text.
Any help will be appreciated.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Jan 17, 2015, 3:21 PM
VulpesPosted Jan 13, 2015, 9:06 AM
// in Form_Load
// in a button Click, textBox Leave or wherever you want to put it
int k = 0; // or whatever
Marvin kakuruPosted Jan 13, 2015, 9:05 AM
Vikram AgrawalPosted Jan 13, 2015, 8:07 AM
you can do this in GridViewSelectedIndexChange event.
in that you will get the selected row and in that row you can find your column's value and match with textbox.
like
string txt = (grid1.SelectedRow.FindControl("MyLabel") as Label ).Text;
Khargesh RajputPosted Jan 13, 2015, 6:57 AM
string val1= GridView1.SelectedRow.Cells[0].Text;
string val2= GridView1.SelectedRow.Cells[1].Text;
Piyush PansuriyaPosted Jan 13, 2015, 6:05 AM
you can get on selection_changed event of datagridview.
i.e.
(datagridview.selecteditem as