Sunday 29 October 2017

Retrieve values from GridView on SelectedIndex_changed

This is very different from rowindex_changed

For C#

Find the control, probably a label, of the data you want to retrieve.

    //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;

No comments:

Post a Comment