Menu
Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Components & Controls
Grids
Web Grids
Multiple DataKeyNames From One GridView
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="evad4682" data-source="post: 61278" data-attributes="member: 4642"><p>Hello all</p><p></p><p>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.</p><p></p><p>This is what I have so far</p><p>[CODE]</p><p> Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)</p><p>Handles GridView1.SelectedIndexChanged</p><p> m = Me.GridView1.DataKeys(0).ToString</p><p> A = Me.GridView1.DataKeys(1).ToString</p><p> Me.GridView2.DataBind()</p><p> Me.GridView3.DataBind()</p><p> End Sub</p><p></p><p> Protected Sub SqlDataSource2_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) </p><p>Handles SqlDataSource2.Selecting</p><p> e.Command.Parameters("@messid").Value = m</p><p> End Sub</p><p></p><p> Protected Sub SqlDataSource3_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) </p><p>Handles SqlDataSource3.Selecting</p><p> e.Command.Parameters("@asset").Value = A</p><p> End Sub</p><p>[/CODE]</p><p></p><p>When I debug this code [CODE]m = Me.GridView1.DataKeys(0).ToString[/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?</p><p></p><p>Any help is appreciated. Thanks</p></blockquote><p></p>
[QUOTE="evad4682, post: 61278, member: 4642"] 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 [CODE] 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 [/CODE] When I debug this code [CODE]m = Me.GridView1.DataKeys(0).ToString[/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 [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
Components & Controls
Grids
Web Grids
Multiple DataKeyNames From One GridView
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom