Aman Jen

Aman Jen

  • NA
  • 141
  • 40.5k

redirect Gridview

Jul 15 2013 12:02 PM
Hi


 I have added an external Dll to convert page to pdf file.

Now the issue is if I use Session state to redirect Gridview to new page ,it redirects sucessfully, but if try to covert it to Pdf file on button click event..it just converts the button on page to pdf file...and loaded grid is not copied....

what is happening here i think..page is not maintaining the state on button click event...

plz sugest a solution..


the pdf dll is simple it just converts current page to pdf....I am using Websupergoo & PDFtech.....
issue is webform3 is not maintaining Gridview data on button_click..event...


Below is my code:


Webform 2:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            cn.Open()
            Bind_to_Drop()
            cn.Close()
        End If
     
    End Sub
 
    Public Sub Bind_to_Drop()
        cmd.Connection = cn
        cmd.CommandText = "Select * From Acct_Sum "
        Dim da As New SqlDataAdapter(cmd)
        Dim ds As New DataSet
        da.Fill(ds, "Acct_Sum")
        DP3.DataSource = ds
        DP3.DataTextField = "Loan_code"
        DP3.DataValueField = "Loan_code"
        DP3.DataBind()
        DP3.Items.Insert(0, "Select Item")
    End Sub


 Protected Sub btnshow_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnshow.Click

 Session("@Loan_code") = DP3.SelectedItem.Value
        Server.Transfer("WebForm3.aspx")
 End Sub


Webform3:

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 cn.Open()
     
            bingrid()




        cn.Close()
    End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click


        Dim theDoc As Doc = New Doc()
        Dim theURL As String = "http://localhost:43027/WebForm3.aspx"
        theDoc.AddImageUrl(theURL)
        theDoc.Save("D:\ABCD.PDF")
        theDoc.Clear()
       
    End Sub
    Public Sub bingrid()
        Dim v As String = Session("@Loan_code")
        cmd.Connection = cn
        cmd.CommandText = "Select * From Acct_Sum where Loan_code = '" & v & "'"
              Dim da As New SqlDataAdapter(cmd)
        Dim ds As New DataSet
        da.Fill(ds, "Acct_Sum")
        GD2.DataSource = ds
        GD2.DataBind()
    End Sub
End Class

Webform2:

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="WebForm2.aspx.vb" Inherits="TestBank.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:DropDownList ID="DP3" runat="server" AutoPostBack="True">
    </asp:DropDownList>
    <asp:Button ID="btnshow"  OnClick ="btnshow_Click" runat="server" Text="OtherPage" />
</asp:Content>


Webform3:
-----------------------------------------------------------------------------
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="WebForm3.aspx.vb" Inherits="TestBank.WebForm3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server" >
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server" >
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server" >
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <asp:GridView ID="GD2" runat="server" >
    </asp:GridView>
    </asp:Content>

Thnx
Aman