Pass Session value to HyperLink inside ASP.Net GridView Template Field

Last Reply one year ago By democloud

Posted one year ago

Hello Sir,

I'm trying to make a Gridview column itself as a hyperlink for regenerating reports for that particular row.

I have been using the below code for the same.

<asp:CommandField ShowSelectButton="True" ButtonType="Link" ShowHeader="True" SelectText="Report" ></asp:CommandField>

in Codebehind

 

 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int index = GridView1.SelectedRow.RowIndex;
        clientId = Convert.ToInt32(GridView1.Rows[index].Cells[0].Text);
        string role = obj.Encrypt(Convert.ToString(roleID));
        Response.Redirect("clientreport.aspx?ID=" + role + "&clientId= " + clientId);
    }

Using this I'm able to generate the reports but using my code one new column is getting generated, i want hyperlink to created from where onclick  report should be generated for particular row ID.

Thanks 

 

Results 1 - 5 of 10 12

Posted one year ago

Hello Sir,

I tried this example but not getting how to pass 2 parameters like 

 

 Response.Redirect("clientreport.aspx?ID=" + role + "&clientId= " + clientId);

 

<asp:HyperLinkField DataTextField="Name" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/Details.aspx?Id={0}"
            HeaderText="Name" ItemStyle-Width = "150" />

In the above example how to pass roleId and clientId, clientId will get from onclick of gridview row

 



Posted one year ago

Hello Sir,

One parameter i need to pass from session, how to pass parameter from session. 


Posted one year ago

You are already data in session. So why you need to pass same value again. You can access the Session value in the destination page without passing in query string.