I am trying but open in next window
I am clicking selecting in QueryStringParams1.Aspx page ,second page url like this http://localhost:3951/query/QueryStringParams2.Aspx?TagId=1
Based on that TagId query string value will open In the browser in the same window(Ex:www.asp.net)
After that URL same http://localhost:3951/query/QueryStringParams2.Aspx?TagId=1,I want to chnge TagId=2 based on that TagId value open in the same page(EX:www.bing.com) and so on
Table like this in database
TagId NAME coupounurl
1 asp www.asp.net
2 weblog www.bing.com
3 google www.google.com
Default.aspx
onselectedindexchanging="GvDept_SelectedIndexChang ing" Width="227px">
.CS
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection( @"Data Source=<>;Initial Catalog=productdb;Persist Security Info=True;User ID=<>;Password=<>");
SqlDataAdapter da = new SqlDataAdapter("select * from redirecturl", con);
DataSet ds = new DataSet();
da.Fill(ds, "redirecturl");
Gvurl.DataSource = ds.Tables["redirecturl"];
Gvurl.DataBind();
Gvurl.DataKeyNames = new string[] { "Tagid" };
}
protected void GvDept_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
Gvurl.SelectedIndex = e.NewSelectedIndex;
string Dno = Gvurl.SelectedValue.ToString();
Response.Redirect("~/QueryStringParams2.Aspx?TagId="+Dno);
}
QueryStringParams2.Aspx
EmptyDataText="There Are No Employees In Selected Department"
AutoGenerateColumns="false" Width="99px">
<%--
<%#Eval("coupounurl")%>
--%>
.CS
public partial class QueryStringParams2 : System.Web.UI.Page
{
String URL = "";
protected void Page_Load(object sender, EventArgs e)
{
string Dno = Request.QueryString["TagId"];
SqlConnection con = new SqlConnection( @"Data Source=<>;Initial Catalog=productdb;Persist Security Info=True;User ID=<>;Password=<>");
SqlCommand cmd = new SqlCommand("select coupounurl from redirecturl where customerid=" + Dno, con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
GvRed.DataSource = dr;
GvRed.DataBind();
dr.Close();
object drReader = cmd.ExecuteScalar();
if (drReader != null)
{
URL = drReader.ToString();
}
con.Close();
if (!String.IsNullOrEmpty(URL))
{
Response.Write("");
}
}
I can try this one plz tel me
Replies
Know the answer? Post it — somebody with the same question will find it here.