i have a problem in showing the data in the other page which is saved from one page and should be shown in the other page after immediately saving it. can anyone tell how do it through form collection
here is the code

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim connstr As String
        connstr = ConfigurationManager.ConnectionStrings("gate").ConnectionString()
        Dim conn As New SqlConnection(connstr)
        Dim dr As SqlDataReader
        Dim da As New SqlClient.SqlCommand("select gp_no,belongs_to,from_whom,gp_date,officer_incoming,officer_nic,expected_takeback,purpose from gate_incoming ", conn)
        conn.Open()
        dr = da.ExecuteReader()
        If dr.Read() Then
            so.Text = dr(0).ToString
            dt.Text = dr(3).ToString
            belongto.Text = dr(1).ToString
            fro.Text = dr(2).ToString
            pur.Text = dr(7).ToString
            expected.Text = dr(6).ToString
            name.Text = dr(4).ToString
            officer.Text = dr(5).ToString
        End If
        conn.Close()
        End Sub

can any one give the sites for form collection

Use Session,

Click event handler of Button1 on page1.aspx

void Button1_click(object s,EventArgs e) {
     Session["no"]=10;
     Sesson["name"]="M.R";
     Response.Redirect("Page2.aspx");
  }

Code in page_load handler of page2.aspx

if(Session["no"]!=null) {
    Response.Write(Session["no"] + " " + Session["name"]);
 }
commented: solved! +6

can anyone give the session coding to my code

thanks it's working here is the code

button click event of the first form

Session("gp_no") = so.Text
        Session("yr") = years.Text
        Session("gp_date") = da.Text
        Session("belongs_to") = belongto.Text
        Session("from_whom") = fro.Text
        Session("purpose") = pur.Text
        Session("expected_take") = expected.Text
        Session("officer_incoming") = name.Text
        Session("officer_nic") = officer.Text
        Response.Redirect("incoming_detail.aspx")

pageload of the second form

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim connstr, gpno, yr As String
        connstr = ConfigurationManager.ConnectionStrings("gate").ConnectionString()
        
        Dim conn As New SqlConnection(connstr)
        
        Dim dr As SqlDataReader
        If Session("gp_no") IsNot Nothing Then
            gpno = Session("gp_no")
            yr = Session("yr")
            'Session("belongs_to")
            'Session("from_whom")
            'Session("purpose")
            'Session("expected_take")
            'Session("officer_incoming")
            'Session("officer_nic")
        End If
       
        Dim da As New SqlClient.SqlCommand("select gp_no,belongs_to,from_whom,gp_date,officer_incoming,officer_nic,expected_takeback,purpose from gate_incoming where gp_no=" & gpno & " and year=" & yr, conn)
        conn.Open()
        dr = da.ExecuteReader()
        If dr.Read() Then
            serial.Text = dr(0).ToString
            dt.Text = dr(3).ToString
            belongto.Text = dr(1).ToString
            fro.Text = dr(2).ToString
            pur.Text = dr(7).ToString
            expected.Text = dr(6).ToString
            name.Text = dr(4).ToString
            officer.Text = dr(5).ToString
        End If
        conn.Close()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.