I have Dropdownlist and Button on form.
My code workes like if select item from dropdownlist...it loads data from sqldb to gridview on form, til here its fine
problem is , I want to write code like when I select item from Dropdownlist and click button then selected item data should be loaded to new page in gridview.
Sanjeeb LenkaPosted Jul 13, 2013, 3:21 PM
If you want to pass the value not showing in url then you go for Session to pass the value. it will not shown in url.
Any problem reply.
Aman JenPosted Jul 15, 2013, 7:31 AM
issue is webform3 is not maintaining Gridview data on button_click..event...
Sanjeeb LenkaPosted Jul 15, 2013, 6:18 AM
using ITextsharp. its good
http://www.aspsnippets.com/Articles/Export-ASPNet-Web-Page-with-images-to-PDF-using-ITextsharp.aspx
Aman JenPosted Jul 15, 2013, 6:08 AM
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" %>
Webform3:
-----------------------------------------------------------------------------
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="WebForm3.aspx.vb" Inherits="TestBank.WebForm3" %>
Sanjeeb LenkaPosted Jul 15, 2013, 6:00 AM
just share your aspx and cs code of page. so i can able to solve your problem.
Aman JenPosted Jul 15, 2013, 5:57 AM
In the same app 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....
Thnx
Aman
Aman JenPosted Jul 14, 2013, 12:23 PM
Thanx working...:)
Aman JenPosted Jul 13, 2013, 5:33 AM
Here's one issue.....when I am passing values from string its visible in url....I dont want to show that value in URL how to hide it....becoz even if i am passing value to url directly of dropdownlist..its fetching data to Gridview of that item directly..
Plz help
Thnx
Aman JenPosted Jul 12, 2013, 11:01 PM
Thx for reply,
Solved now..:)
Sanjeeb LenkaPosted Jul 12, 2013, 2:13 PM
if another page then pass the dropdown value as query string to new page on button click. catch that value in that page. and use it to bind the grid by passing it with select query.