Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have two page one default.aspx
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        djfdl();
    }
    private void djfdl()
    {
        SqlDataAdapter adp = new SqlDataAdapter("select * from thousand", ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
        DataSet ds = new DataSet();
        adp.Fill(ds);
        DataList1.DataSource = ds;
        DataList1.DataBind();
    }
    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Response.Redirect("MasterPage.master-Default.aspx?pid="+e.CommandArgument.ToString());
    }
}

SECOND PAGE IS DEFAULT2.ASPX
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;
using System.Configuration;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        datab();
    }
    private void datab()
    {
        string qry = "select * from thousand where pid=" + Request.QueryString["pid"].ToString();
        SqlDataAdapter adp = new SqlDataAdapter(qry, ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
        DataSet ds = new DataSet();
        adp.Fill(ds);
        DetailsView1.DataSource = ds;
        DetailsView1.DataBind();
    }
}
Posted
Updated 20-Aug-14 1:47am
v3
Comments
[no name] 20-Aug-14 7:21am    
Did you forget to ask a question, format your code and provide a description of a problem?
Richard Deeming 20-Aug-14 7:24am    
Your code is susceptible to SQL Injection[^] - use a parameterized query instead.

Also, you haven't provided any information about what's not working.
[no name] 20-Aug-14 7:48am    
Response.Redirect(Default.aspx?pid="+e.CommandArgument.ToString());
It shoud use "MasterPage.master- with defualt. Follow as above code

1 solution

u can use this code..
Eg:

HTML
IMGoBJ.Id = Convert.ToInt32(e.CommandArgument);
Response.Redirect("~/Pages/rajeeshmenoth.aspx?Qry=" + IMGoBJ.Id);
// second page..page load
objNews.Id = Convert.ToInt32(Request.QueryString["Qry"]);    
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900