Dear Friends,
i have a requirement, there is an Web form named Form2 in which there is gridview
the gridview contains columns(kit Name,Kit Type,Kit Units).
the following values comes in Gridview Form from a Dropdown value 'CTNO'.
which is been field in a Previous Form named Form1 in Application.
I want a link in Form2 Gridview, which will redirect all the details to Form1 in readONly format.
how can it be done!!!
pl reply.
aamir
Aamir KhanPosted Jun 25, 2012, 3:24 AM
Jignesh TrivediPosted Jun 25, 2012, 2:45 AM
As per my understanding you que is "you have two aspx pages called a.aspx and b.aspx, and a.aspx containing gridview with hyperlink, if any one click on that hyperlink than system will redirect to b.aspx and b.aspx also contain grid view".
If i am right that follow step given below.
1) A.aspx - create grid view with column hyperlink.
...
...
here "DataNavigateUrlFields" pass property name of Id and DataTextField pass property name of Display name and DataNavigateUrlFormatString pass url.
2) now on page load of b.aspx you write your grid bind logic.
3) you can get value selected value of grid row by Request.QueryString["Id"]
hope this will help you.
Aamir KhanPosted Jun 25, 2012, 1:38 AM
how to fill a gridview on selection of a Hyperlink in Gridview of another Form.
Regards,
aamir
Satyapriya NayakPosted Jun 24, 2012, 1:08 PM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test3.aspx.cs" Inherits="Display_related_records_gridview.test3" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Display_related_records_gridview
{
public partial class test3 : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindgrid();
}
}
private void bindgrid()
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from employee";
com = new SqlCommand(str, con);
SqlDataReader reader;
reader = com.ExecuteReader();
g1.DataSource = reader;
g1.DataBind();
con.Close();
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test4.aspx.cs" Inherits="Display_related_records_gridview.test4" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Display_related_records_gridview
{
public partial class test4 : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
string s1;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
s1 = Request.QueryString[0];
str = "select * from employee where empid='" + s1 + "'";
com = new SqlCommand(str, con);
SqlDataReader reader;
reader = com.ExecuteReader();
if (reader.Read())
{
Label1.Text = reader["empname"].ToString();
Label2.Text = reader["empaddress"].ToString();
Label3.Text = reader["empsal"].ToString();
Label4.Text = reader["empphone"].ToString();
Label5.Text = reader["empfax"].ToString();
Label6.Text = reader["empcity"].ToString();
Label7.Text = reader["empstate"].ToString();
Label8.Text = reader["empzip"].ToString();
Label9.Text = reader["emplic"].ToString();
Label10.Text = reader["empstatus"].ToString();
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
}
Thanks