Hello all
I have a webform with three GridViews on it. The first GridView populates a summary of information at the Form_Load event. I have set this gridview to be selectable. When an item is selected off this gridview I need it to pass two different values - one to each of the subsequent gridviews (GridView2, GridView3). I have set two DataKeyNames in the properties of GridView1. From checking around I guess that I need to set up the Selecting event for GridView2 and GridView3 for this to work - which is where I am stuck.
This is what I have so far
When I debug this code
it literally returns System.Web.UI.WebControls.Datakey as a string value. I get the same results for the next line. My code then bombs out when I try to databind - Cannot convert nvarchar to numeric. The two datakeys are numeric values. How do I get the "actual" values of the datakeys for the selected row?
Any help is appreciated. Thanks
I have a webform with three GridViews on it. The first GridView populates a summary of information at the Form_Load event. I have set this gridview to be selectable. When an item is selected off this gridview I need it to pass two different values - one to each of the subsequent gridviews (GridView2, GridView3). I have set two DataKeyNames in the properties of GridView1. From checking around I guess that I need to set up the Selecting event for GridView2 and GridView3 for this to work - which is where I am stuck.
This is what I have so far
VB.NET:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Handles GridView1.SelectedIndexChanged
m = Me.GridView1.DataKeys(0).ToString
A = Me.GridView1.DataKeys(1).ToString
Me.GridView2.DataBind()
Me.GridView3.DataBind()
End Sub
Protected Sub SqlDataSource2_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
Handles SqlDataSource2.Selecting
e.Command.Parameters("@messid").Value = m
End Sub
Protected Sub SqlDataSource3_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
Handles SqlDataSource3.Selecting
e.Command.Parameters("@asset").Value = A
End Sub
When I debug this code
VB.NET:
m = Me.GridView1.DataKeys(0).ToString
Any help is appreciated. Thanks