sny23vpb
asked on
Selected Value Gridview Row Command
Is there someway to perform this type of function to determine which value was selected when a user clicks on a button that runs the row command ?
It keeps telling me that I need to create a new instance of that object.
Thanks for any help
Session("CustID") = GridView2.SelectedValue.To String()
It keeps telling me that I need to create a new instance of that object.
Thanks for any help
Session("CustID") = GridView2.SelectedValue.To
ASKER
Thank you; but when I use this code ? e.CommandSource.parent returns the System.web information below rather than the Index of the Cell which called the command.
Any other thoughts ?
Thanks
? e.CommandSource.parent RETURNS:
{System.Web.UI.HtmlControl s.HtmlForm }
System.Web.UI.HtmlControls .HtmlForm: {System.Web.UI.HtmlControl s.HtmlForm }
Any other thoughts ?
Thanks
? e.CommandSource.parent RETURNS:
{System.Web.UI.HtmlControl
System.Web.UI.HtmlControls
How is the Button defined in the GridView HTML? Did you define a CommandName for the Button.
ASKER
I added a new 'button field' to the grid and called it Edit with a command name 'EditCustomer'
Unfortunately I can't use the grid built in edit functionality for this project; I need to open a separate form with many more fields to allow the user to edit - so I need that customer number or row ID when they click the edit button so that when the next form opens with the code below; it knows which customer to bring into the edit screen.
Thanks for any help.
Protected Sub GridView2_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls. GridViewCo mmandEvent Args) Handles GridView2.RowCommand
If e.CommandName = "EditCustomer" Then
Response.Redirect("CustEdi t.aspx")
End If
End Sub
Unfortunately I can't use the grid built in edit functionality for this project; I need to open a separate form with many more fields to allow the user to edit - so I need that customer number or row ID when they click the edit button so that when the next form opens with the code below; it knows which customer to bring into the edit screen.
Thanks for any help.
Protected Sub GridView2_RowCommand(ByVal
If e.CommandName = "EditCustomer" Then
Response.Redirect("CustEdi
End If
End Sub
Add a template field to a grid.
Edit" />
This will give you Edit link in a column in each row. This link will redirect user to custedit.aspx page with customer ID in a query string.
R
Edit" />
This will give you Edit link in a column in each row. This link will redirect user to custedit.aspx page with customer ID in a query string.
R
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you !
((Button)(e.CommandSource)
This will give the cell that sent the postback