how to bind details using hyperlink in gridview?
hi i am developing student management system..here i have attached the image...when i clicking view details of murali (or) others.the whole details of murali should be bind on new form... can any one help me out how to code....it's urgent .....

Sanjeeb LenkaPosted Jul 24, 2013, 6:44 AM
in grid:
OnRowCommand="GridView1_RowCommand">
runat="server">
in .cs add this event:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "passdata")
{
Response.Redirect("~/studprof.aspx?T_ID=" + e.CommandArgument.ToString());
}
}
now you can able to get the id in new form. just get that id and pass that id to database to get the info of particular id.
to get the id in next page:
string id = Request.QueryString["T_ID"];
Sanjeeb LenkaPosted Jul 24, 2013, 7:25 AM
protected void Page_Load(object sender, EventArgs e)
{
Con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=studentmgmt;Integrated Security=True");
int id = Convert.ToInt32(Request.QueryString["T_ID"]);
bind(id);
}
public void bind(int id)
{
Sda = new SqlDataAdapter("Select [Name],Fathers_Name,Class,Section,Batch,Date_Of_Berth,Sex,[Address] from student where T_ID='" + id + "'", Con);
Sda.Fill(dt);
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
selva kumarPosted Jul 24, 2013, 7:19 AM
selva kumarPosted Jul 24, 2013, 7:14 AM
Conversion failed when converting the varchar value '<%Eval("T_ID")%>' to data type int.
my code is...
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class studprof : System.Web.UI.Page
{
SqlConnection Con;
SqlDataAdapter Sda=new SqlDataAdapter ();
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
Con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=studentmgmt;Integrated Security=True");
bind();
}
public void bind()
{
string id=Request.QueryString["T_ID"];
Sda = new SqlDataAdapter("Select [Name],Fathers_Name,Class,Section,Batch,Date_Of_Berth,Sex,[Address] from student
where T_ID='" +id+ "'", Con);
Sda.Fill(dt);
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
}
selva kumarPosted Jul 24, 2013, 6:31 AM
Sanjeeb LenkaPosted Jul 24, 2013, 6:18 AM