Reputation: 12842
my grid view contains a column having a text box. when i post back the page, i have to select all the rows where the value of each row's text box is > 0. how can i do it ?
Upvotes: 0
Views: 75
Reputation: 4666
Try something like this:
foreach (GridViewRow row in GridView1.Rows) {
// Selects the text from the TextBox
// which is inside the GridView control
string textBoxText = ((TextBox)row.FindControl("TextBox1")).Text;
// do waht ever
}
Upvotes: 1
Reputation: 4870
You could use LINQ.
var selectedRows = GridView1.Rows.OfType<GridViewRow>().Where(r=>((TextBox)row.FindControl("TextBox")).Text=="val")
and then foreach over the selected rows
Upvotes: 1