Hi
I'm trying to create a link to send a value to the next page, and then use this value on this page.
Inside a Datalist.
<asp:linkButton ID="Datalnk1" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "ID")%>' CommandName="lnk" PostBackURL='~/Page/Event/popup.aspx' runat="server"><%#DataBinder.Eval(Container.DataItem, "ID")%
></asp:Linkbutton>
link retrieves the correct SQL info (ID) and open the next page Popup.aspx
Page Popup.aspx
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<div id="meldpå" runat="server">
Event:
<asp:Label ID="confirmlabel" runat="server"></asp:Label>
<br />
<br />
<asp:TextBox ID="name1" runat="server">Navn:</asp:TextBox>
<br />
<br />
<asp:Button ID="inexsql1" runat="server" Text="Send !!" OnClick="inexsql1_Click" />
codefile Popup.aspx.vb
Partial Class Page_Event_popupPage
Inherits System.Web.UI.Page
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim name As String
Public Sub Page_Load()
Dim MainContent As ContentPlaceHolder = CType(Page.Master.FindControl("MainContent"), ContentPlaceHolder)
Dim ID As String = String.Empty
If Not String.IsNullOrEmpty(Request.QueryString("ID")) Then
ID = Request.QueryString("ID")
End If
confirmlabel.Text = "ID"
End Sub
Protected Sub inexsql1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim MainContent As ContentPlaceHolder = CType(Page.Master.FindControl("MainContent"), ContentPlaceHolder)
Dim name As TextBox = TryCast(Page.FindControl("name1"), TextBox)
con = New SqlConnection("Data Source=VINYW8;Initial Catalog=Events;Integrated Security=True")
cmd = New SqlCommand("INSERT INTO Påmeldt (Event, Navn)VALUES(@R1, @R2)", con)
cmd.Parameters.AddWithValue("@R1", ID)
cmd.Parameters.AddWithValue("@R2", name.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Sub
End Class
trouble is that I do not get the value in the link with me to the next page, and i think the code in the first page has an error.
but I'm not sure if get and store, to use later on is correct to. (on popup page)
and I use Master.Page with content placeholders.