Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding DetailsView from Gridview selection other than selectedvalue.

Status
Not open for further replies.

dstrange

Programmer
Nov 15, 2006
87
CA
Is this possible?
I'd like to have my DetailsView based off of the selection of the Gridview from the value in the 3rd column. I'm used to doing this based off of the gridview.selectedvalue but I am not sure how to do it based of off another gridview column. Thanks in advance.
 
a gridview can have multiple datakeys, make the value of column 3 a datakey value as well. when you load your dataview select the record using the additional datakey. then it doesn't matter what column the value is, or if it's even displayed.

something like this
Code:
<gridview datakeys="id,additional_column">
Code:
void handler_for_select_gridview_row(object sender, SelectedGridViewRowEventArgs e)
{
   var key = mygride.datakeys[e.SelectedIndex]["additional_column"];
   mydataview.DataSource = get_record_based_on(key);
   mydataview.DataBind();
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top