Hi,
How to set hyperlink to the primary key column in grid view. Instead of using edit update delete actions in grid view, i wanted to click on primary key column and it should navigate me to the respective pages.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Sep 5, 2013, 8:27 AM
Prasenjit DeyPosted Sep 5, 2013, 5:44 AM
sita kPosted Sep 5, 2013, 5:30 AM
With your code I am able to achieve what I wanted but I am facing errors :
1.I am trying to avoid emp_id in the gridview query since i am binding it in the link button.By doing this way I am having binding issues.
2.If I do select emp_id then I am having two emp_id columns one with link and one without.How to resolve this?
Sanjeeb LenkaPosted Sep 4, 2013, 1:22 AM
Take a link button in gridview item template. and bind the id to linkbutton text and to command argumet and write command name in that. then write the code in gridview rowcommand to catch the id then pass it to next page.
Ex:
in cs:
protected void gvArea_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "NEdit")
{
int id=Convert.ToInt32(e.CommandArgument.ToString());
Response.Redirect("");//pass the id as query string here to next page
}
}
sita kPosted Sep 4, 2013, 12:45 AM
I got an employee table with columns emp_id, name and sal. Now in the grid view I would like to provide hyperlink to emp_id.If I would like to perform update and delete operations after selecting the hyperlink i.e emp_id i should navigate to update page. To make it simple i don't want to add separate edit or delete actions in the grid view.
Sanjeeb LenkaPosted Sep 4, 2013, 12:33 AM
plz provide more details.