View Full Version : Setting a details view

05-03-2012, 05:57 PM
Hey guys, I have a gridview where I allow the user to select one row, then that populates a details view. From here, I would like to populate other detailviews based on a uniqueID that is contained in the first detailsview selected in the gridview. How do I do that?

For example a uniqueID is clicked on in the gridview, then that unique ID is used to populate a row in the first details view, then that same unique ID must be taken from the details view, and a sql query performed on this same table to find a parent uniqueID and detail information. How do I do this?

05-03-2012, 07:23 PM
this can get complex pedning what/how you want to do it- if you want to do it all client side (ie no postback) you will need to populate 'something' and then handle unhiding various aspects using javascript...

to do this via postback (much easier) you would do it all in the code behind.... clicking on the uniqueID would have an associated event handler that would do two things- one is populate a detailsview (or create a new one) and the other would be to fire a SQL query.

You have all the information- you almost answered your own question- I think the only place it gets to be more complex is if you want it to happen all client end via javascript-

post-back with what you need help/clarification/guidance on,
good luck :)

05-04-2012, 02:37 PM
Okay heres what I've got so far, under App-Data, I've got an access database called AncestorsDotNet.accdb. Below is an event handler. I want to access this database and get the gridview1 uniqueid and look up another uniqueid via a fatherid. from there I want to set another form field or details view control. How do I do this?

Protected Sub View1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged


' create a new SqlConnection object with the appropriate connection string
Dim sqlConn As New SqlConnection() 'OleDbConnection i
' open the connection
'do some operations here...
'close the connection

Dim command As New SqlCommand("SELECT * from TblDotNetAncestorsTree", sqlConn)


End Sub