Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to bind name in gridview through linkbutton or hyperlink.. when I click on hyperlink it redirects to an another form and data had to be fetched from sql server regarding this name of id and assingned data into appropriate controls in that form..
Ive done as following method. but
it works fine.. but i need to pass data to the second form controls..
ex: name = txtname.text. the name and other data has to be appear to the controls in the second form
when i execute this one nothing is showing , no error as well
asp page

<asp:LinkButton ID="lnkname" runat="server" Font-Underline="false"

CommandArgument='<%# Bind("stu_id")%>' CommandName="view" Text='<%# Eval("stu_name") %>'

c sharp code in source form

protected







void grdipreg_Rowcommand(object sender, GridViewCommandEventArgs e)

{







if (e.CommandName == "view")

{







// Your page name with query String








Response.Redirect(





"IPRegistration.aspx?stu_id=" + e.CommandArgument.ToString());

}

}


c sharp code in destination form


protected

void Page_Load(object sender, EventArgs e)

{



if (!IsPostBack)

{



if (Request.QueryString["stu_id"] != null)

{

con.Open();






SqlCommand cmd = new SqlCommand("select * from stu_info2 where stu_id='" + Request.QueryString["stu_id"].ToString() + "'", con);



SqlDataReader dr;

dr = cmd.ExecuteReader();



if (dr.Read())

{



string stuid = dr[0].ToString();



string stuname = dr[1].ToString();

stuname = TextBox2.Text;

stuid = txtstuid.Text;

}

}

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900