Showing posts with label Get the value of Selected Row From Gridview. Show all posts
Showing posts with label Get the value of Selected Row From Gridview. Show all posts

Monday, July 13, 2009

Get the value of Selected Row From Gridview

//Just Before the page load define the variable
string textBoxCompanyName, textBoxContactName, textBoxCustomerID;
//Then on the button click event get the values from the grid
//Here dvCustomerDetail is the name of a Gridview
foreach (GridViewRow row in dvCustomerDetail.Rows)
{
textBoxCustomerID = ((TextBox)row.FindControl("tbxCustomerID")).Text;
textBoxCompanyName = ((TextBox)row.FindControl("tbxCompanyName")).Text;
textBoxContactName = ((TextBox)row.FindControl("tbxContactName")).Text;
}