Hi
I have to retrieve the value from the DB & display on the textboxes which are in Default2.aspx based on the value entered in the textbox which is in Default.aspx.
For that I have given the coding in Default.aspx as
If I type the value in the TextBox & click the button which is in Default.aspx then it should Redirect to the Default2.aspx & retrive & display the data from the DB.For that in Default2.aspx I have given the coding as
In Form Load, I have given the coding as
But its not running & also it is not showing any error.
I have to retrieve the value from the DB & display on the textboxes which are in Default2.aspx based on the value entered in the textbox which is in Default.aspx.
For that I have given the coding in Default.aspx as
Code:
<form id="form1" runat="server" method="post" action="Default2.aspx"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
Code:
<form id="form1" runat="server" method="get" action="Default.aspx"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
Code:
Imports System.Data.SqlClient
Imports System.Data
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim con As New SqlConnection("user id=sa;password=cast;database=sjc;server=AURORA-SERVER")
con.Open()
Dim sql As String = "select * from ITEMS where ID='" & Request.Form("a") & "'"
Dim cmd As New SqlCommand(sql, con)
Dim dr1 As SqlDataReader
dr1 = cmd.ExecuteReader()
While (dr1.Read())
TextBox1.Text = dr1.GetValue(2).ToString()
TextBox2.Text = dr1.GetValue(3).ToString()
TextBox3.Text = dr1.GetValue(7).ToString()
TextBox4.Text = dr1.GetValue(5).ToString()
End While
End Sub
End Class
Comment