I need your help.
I have two .aspx pages. In first page we have two Textbox i want display record from database bind in datalist next page according search first page TextBox. How it possible?
Loading
I need your help.
I have two .aspx pages. In first page we have two Textbox i want display record from database bind in datalist next page according search first page TextBox. How it possible?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Krishna GaradRank #191 · 12.8K reputationPosted Jan 9, 2012, 7:26 PM EST
your description is not clear but as per my understanding I think so you need to pass the values of first page.aspx textbox to another page and with that values you want to bind datalist from database. If it like that you can use querystring like bellow.
Response.Redirect("~/Page2.aspx?_val1="+textbox1.Text+"&_val2="+TextBox2.Text);
Write this in firstpage.aspx where you want to redirect on another page. And in page2.aspx load event load the values from database and bind to detailsview like
Page_load
{
if(Request.QueryString["_val1"]!=null && Request.QueryString["_val2"]!=null)
{
string _val1=Request.Querystring["_val1"];
string _val2=Request.QueryString["_val2"];
//Bind datalist by fetching records from database.
}
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 9, 2012, 7:46 PM EST
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="First.aspx.cs" Inherits="First" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class First : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Second.aspx?id=" + TextBox1.Text);
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Second.aspx.cs" Inherits="Second" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Second : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
string s1;
string str;
protected void Page_Load(object sender, EventArgs e)
{
s1 = Request.QueryString["id"];
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select count(*)from Mobile where mname='" + s1 + "'";
com = new SqlCommand(str, con);
int count = Convert.ToInt32(com.ExecuteScalar());
if (count > 0)
{
bindlist();
}
else
{
Response.Write("Sorry No records found");
}
}
void bindlist()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select * from Mobile where mname='" + s1 + "'";
com = new SqlCommand(str, con);
SqlDataReader reader;
reader = com.ExecuteReader();
DataList1.DataSource = reader;
DataList1.DataBind();
reader.Close();
con.Close();
}
}
Thanks
If this post helps you mark it as answer