hypertext in gridview
i have a gridview with rows of a particular column(name of employees) set as hyperlink. when i click on the hyperlinks all should direct to the same page.however i want the name of the employee to be sent to the directed page for further processing.how do i achieve this? i have already created the names of the employees as hyperlink , but m unable to send the name of the employee.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink link = new HyperLink();开发者_高级运维
link.Text = e.Row.Cells[0].Text;
link.NavigateUrl = "Goal_AssignmentPage.aspx";
e.Row.Cells[0].Controls.Add(link);
}
}
i should be able to access the string within e.Row.Cells[0].Text in the Goal_AssignmentPage.aspx
just append the link.text witht he navigatio url as i did
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink link = new HyperLink();
link.Text = e.Row.Cells[0].Text;
link.NavigateUrl = "Goal_AssignmentPage.aspx?employeename=" + link.Text; // change in your code
e.Row.Cells[0].Controls.Add(link);
}
}
In Goal_AssignmentPage.aspx ->> page load method
write Request.QueryString["employeename"]
to get value
精彩评论