Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

posting textbox value to aonther webform 1

Status
Not open for further replies.

knaya

MIS
Dec 4, 2003
51
US
i'm running into one problem after the other.. helppp.. i'm trying to post the value from textbox A on a login page to Textbox B on a members page.. I'm using Server.Transfer("members.aspx", true) on the login page and Response.Write(Request.Form("txtuser")) on the members page and it works except the username is no-where in Textbox B, instead it appears at the top of my page and if i do change the code, it doesnt even appear at all.. any help with how to change this.. thanks ya'll..
 
You could pass this as a QueryString

Dim strRedirect As String
strRedirect = "Members.aspx?SendString=" & textboxA.Text
Response.Redirect(strRedirect, True)


In the Page Load of the second page set the text.

TextBoxB.Text = Request.QueryString("SendString")

Hope this helps!

Hope everyone is having a great day!

Thanks - Jennifer
 
Jennifer,
How can i give you 10 stars, i tried every single way i knew and boom, your method works.. Muchos gracious, i really appreciate it.
 
Jzelhart,
Please I have a similar issue. This is my very first ASP.Net project and I am just as blank.
I tried your example and it work great for a single string,(ie. I was able to poplate only one textbox) but I want to pass multiple strings. I am reading from a DataGrid with 6 columns, and I want to pass or populate these same fields on the next Form (Form2). I am having problems getting the values out of the cells.
This is how I am doing it. There is a "Select" column on my DataGrid. If I click on this "Select" Column, it selects the Row, then transfers me to Form2, where it is supposed to populate the corresponding Textboxes, Labels and drop down fields, with the records from the selected row.
I tried using the [ e.item.Cells().Controls,textbox) ] to get my values into variables, but the DataGrid_SelectedIndexChanged() method doesn't support this.
Can you help me out please.
 
For DDLs...
Dim tstatID As DropDownList = e.Item.Cells(6).FindControl("IncStatusDDL")
Dim getStatID As String = tstatID.SelectedItem.Value
Dim statID As Integer = Ctype(getStatID, Integer)

For standard boxes...
Dim IncidentID As Integer = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim ClientName As String = e.Item.Cells(3).Text

Your datagrid need to be in edit mode to call them textboxes. you have to specify which cell and controls in the (), unless you omitted them in your post.
 
I would use a Hyperlink Column putting the key in the URL field. Then get the data using that key to limit your dataset when setting the values for the textboxes.

<asp:HyperLinkColumn Text="Print" Target="_blank" DataNavigateUrlField="Table_ID"
DataNavigateUrlFormatString="NewWebForm.aspx?Table_ID={0}"></asp:HyperLinkColumn>


Page Load Code on NewWebForm.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim strConn As String = "server=Server;uid=Login;pwd=Password;Initial Catalog=DatabaseName"
Dim conn As SqlConnection
Dim dr As SqlDataReader
Dim strSQL As String = "SELECT * FROM Table WHERE Table_ID = @strID"
Dim cmd As SqlCommand

lblError.Text = ""

Try
conn = New SqlConnection(strConn)
cmd = New SqlCommand(strSQL, conn)

cmd.Parameters.Add("@strID", SqlDbType.Int).Value = Request.QueryString("Table_ID")
conn.Open()
dr = cmd.ExecuteReader

Do While dr.Read
Me.Textbox.Text = dr("FieldName_VC")
Me.lblLabel.Text = dr("AnotherField_VC")
Loop

Catch ex As Exception
lblError.Text = "A problem was found. Please try again."
Finally
If Not conn Is Nothing Then
conn.Close()
End If
If Not dr Is Nothing Then
dr.Close()
End If
End Try
End Sub


Hope this helps!

Hope everyone is having a great day!

Thanks - Jennifer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top