Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guy's,

I have a grid which shows product version's and have a few link buttons like edit, delete, preview etc.
On click of edit button i want to get the Product ID and Version ID and redirect to some xyz.aspx page wher the product details can be edited.
Here is how my Grid looks.
<asp:TemplateField HeaderText = "Edit">
<ItemTemplate>
<asp:LinkButton ID="Edit" runat="server" CommandName="Add" >"Edit"</asp:LinkButton>
<ItemTemplate>

This is how i have defined my Edit Link button inside the grid.
Click of link button i am tracking in gridview_RowCommand.
Here i want to get the VersionID and ProductID and Redirect to another page.
Please help me.

I am Real New to Coding. I did a bit of google but non of the solutions are helping me.
Posted
Updated 16-May-11 20:48pm
v3

1 solution

define command arguments in your link button

in row_command event handeler you can retrieve your command arguments
use response.redirect to go to another page and pass the arguments as query string.
 
Share this answer
 
Comments
ubaidh sayed 17-May-11 2:49am    
As i said i am real new to coding.
How can i add command arguments ??
ubaidh sayed 17-May-11 2:55am    
i am binding the grid using a datatable.
so do you want me to do something like
<asp:LinkButton id="LinkButton1"
Text="Order Item 10001"
CommandName="Edit"
CommandArgument="VersionID" [This i have id datatable ]
runat="server"/>
saxenaabhi6 17-May-11 3:03am    
define arguments like this
CommandArgument='<%# Bind("VersionID") %>
on your code

protected void gridView_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if( e.CommandName == "Add")
{
Response.Redirect("/your page.aspx?VersionID=" + e.CommandArgument.ToString());
}
}
ubaidh sayed 17-May-11 3:24am    
Thanks a million saxenaabhi6 .
That worked for me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900