Pls Check below code,I want to retrieve information related to linkbutton
***********First Aspx Page ***************
DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"
GridLines="None" onrowcommand="gvForum_RowCommand">
'>
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT tbl_Forum.ForumTitle, tbl_ForumTypes.ForumType, UserInfo.UserName, tbl_Forum.PostDate FROM tbl_Forum INNER JOIN tbl_ForumTypes ON tbl_Forum.ForumTypeId = tbl_ForumTypes.ForumTypeId INNER JOIN UserInfo ON tbl_Forum.UserId = UserInfo.UserId">
***********First Aspx.cs Code********
protected void gvForum_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandArgument != null)
{
Response.Redirect("~/Forum/UserQuest.aspx?UserName=" + e.CommandArgument.ToString());
}
}
*********Second Aspx Page*********i.e /Forum/UserQuest.aspx
********Second Aspx.cs Code***********
protected void Page_Load(object sender, EventArgs e)
{
string name = Convert.ToString(Request.QueryString["UserName"]);
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\ASPNETDB.MDF;Integrated Security=True;User Instance=True";
con.Open();
SqlCommand cmd = new SqlCommand("SELECT tbl_Forum.ForumTitle, tbl_ForumTypes.ForumType, UserInfo.UserName, tbl_Forum.PostDate FROM tbl_Forum INNER JOIN tbl_ForumTypes ON tbl_Forum.ForumTypeId = tbl_ForumTypes.ForumTypeId INNER JOIN UserInfo ON tbl_Forum.UserId = UserInfo.UserId WHERE UserInfo.UserName ="'+name+'"", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
//DataSet ds = new DataSet();
//da.Fill(ds);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
con.Close();
}
please help me out to try solve
after click on linkbutton in first gridview it will redirect to second page with another gridview in which all information related to linkbutton exist.
i.e if i click on username(suppose 'abc') of linkbutton of first gridvu den i wil get all question posted by that username only in second gridvu
Satyapriya NayakPosted Jan 22, 2014, 4:55 AM
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test3.aspx.vb" Inherits="test3" %>
test3.aspx.vb code
Imports System.Data
Imports System.Data.SqlClient
Partial Class test3
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim con As New SqlConnection(strConnString)
Dim str As String
Dim com As SqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
bind()
End Sub
Sub bind()
con.Open()
str = "select * from employee"
com = New SqlCommand(str, con)
Dim reader As SqlDataReader
reader = com.ExecuteReader()
g4.DataSource = reader
g4.DataBind()
con.Close()
End Sub
End Class
test4.aspx code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test4.aspx.vb" Inherits="test4" %>
test4.aspx.vb code
Imports System.Data
Imports System.Data.SqlClient
Partial Class test4
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim con As New SqlConnection(strConnString)
Dim str As String
Dim com As SqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Dim s1 As String
Dim dt As DataTable
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
con.Open()
s1 = Request.QueryString(0)
str = "select * from employee where empid='" + s1 + "'"
com = New SqlCommand(str, con)
g5.DataSource = com.ExecuteReader
g5.DataBind()
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
End Sub
End Class
Biswa Pujarini MohapatraPosted Jan 22, 2014, 4:08 AM
try this code