Hi Payalsh,
Please refer below sample.
DataBase
I have made use of the following table tblFilePath with the schema as follows.
HTML
Default
<table>
<tr>
<td>Enter Id:
<asp:TextBox ID="txtId" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="Submit" /></td>
</tr>
</table>
Home
<table>
<tr>
<td>ImageName :
<asp:Label ID="lblImageName" runat="server"></asp:Label></td>
</tr>
<tr>
<td>Path :
<asp:Label ID="lblPath" runat="server"></asp:Label></td>
</tr>
</table>
Namespaces
C#
using System.Data.SqlClient;
using System.Configuration;
VB.Net
Imports System.Data.SqlClient
Imports System.Configuration
Code
C#
Default
protected void Submit(object sender, EventArgs e)
{
Response.Redirect("Home.aspx?id=" + txtId.Text);
}
Home
{
string imageName = lblImageName.Text;
string path = lblPath.Text;
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("Select * From tblFilePath WHERE Id = @id", con))
{
cmd.Parameters.AddWithValue("@Id", Request.QueryString["id"]);
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
lblImageName.Text = sdr["ImageName"].ToString();
lblPath.Text = sdr["Path"].ToString();
}
con.Close();
}
}
}
VB.Net
Default
Protected Sub Submit(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("Home.aspx?id=" & txtId.Text)
End Sub
Home
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim imageName As String = lblImageName.Text
Dim path As String = lblPath.Text
Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(conString)
Using cmd As SqlCommand = New SqlCommand("Select * From tblFilePath WHERE Id = @id", con)
cmd.Parameters.AddWithValue("@Id", Request.QueryString("id"))
con.Open()
Dim sdr As SqlDataReader = cmd.ExecuteReader()
If sdr.Read() Then
lblImageName.Text = sdr("ImageName").ToString()
lblPath.Text = sdr("Path").ToString()
End If
con.Close()
End Using
End Using
End Sub
Screenshot