Rajveer singh

Rajveer singh

  • 803
  • 1k
  • 248.9k

how to find our session value in grid view

Nov 18 2015 12:28 PM
my aspx code
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataKeyNames="idno" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="title">
<ItemTemplate>
<asp:HyperLink ID="hgb" Target="_blank" runat="server" Text='<%# Eval("link_level3") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
 
cs.code
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
bind();
}
public void bind()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "data source=RANA; uid=sa;password=master; database=mib;";
string qu = "select link_level3,idno from level3 where language='eng'";
SqlDataAdapter da = new SqlDataAdapter(qu, con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink hl = (HyperLink)e.Row.FindControl("hgb");
if (hl != null)
{
DataRowView drv = (DataRowView)e.Row.DataItem;
Session["id"] = drv["idno"].ToString();
//string companyname = drv["CompanyName"].ToString();
hl.NavigateUrl = "~/Default2.aspx?idno=" + Session["id"].ToString();
}
}
}
}
 this code prblem here
 
only find out one session id in gridview of last row 
 
i want click any row find session value this row  
 
i want use only session not query string 

Answers (1)