Fetching data from gridview to label in another form.
-
In C#, .NET 2.0. I have a gridview in frm_Report which looks like this. i have used the sqldatasource to bind the data. In my another form frm_Show is basically this. When user select the hyperlink View, the hyperlink will grab value of Stud_Admin of the selected row in gridview and display it at Label1. What is the next code should I add? thanks in advance. Much appreciated.
-
use Row.RowIndex property to get the selected row.. use RowCommand event of GridView.
Regards, Jay
I don't know what to do next. By getting the values, how will the hyperlink be clever to pass value to label in another form. And what is the syntax for Label1.text = ? By using findcontrol? And
protected void GridView8_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow row = GridView8.Rows[0]; }
thanks in advance. Much appreciated.
-
In C#, .NET 2.0. I have a gridview in frm_Report which looks like this. i have used the sqldatasource to bind the data. In my another form frm_Show is basically this. When user select the hyperlink View, the hyperlink will grab value of Stud_Admin of the selected row in gridview and display it at Label1. What is the next code should I add? thanks in advance. Much appreciated.
If the Stud_Admin text is simple, you may consider passing the value along with the url in the query string (set this
DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}"
)so that you can get it from the Request object in the next page . In addition, you still have many other choices: + Try to retrieve again in DB based on the id passed from the source page when the text is long. + Try to use the LinkButton, so before redirecting to the next page you can save the text in the Session. -
If the Stud_Admin text is simple, you may consider passing the value along with the url in the query string (set this
DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}"
)so that you can get it from the Request object in the next page . In addition, you still have many other choices: + Try to retrieve again in DB based on the id passed from the source page when the text is long. + Try to use the LinkButton, so before redirecting to the next page you can save the text in the Session.:-D Thank you. It works.
minhpc_bk wrote:
(set this DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}" )
But I was just wondering what does Stud_Admin={0} means? If I want to pass two values which is Stud_admin and the next column just next to Stud_Admin? What will the longer DataNavigateUrlFormatString = be?
thanks in advance. Much appreciated.
-
:-D Thank you. It works.
minhpc_bk wrote:
(set this DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}" )
But I was just wondering what does Stud_Admin={0} means? If I want to pass two values which is Stud_admin and the next column just next to Stud_Admin? What will the longer DataNavigateUrlFormatString = be?
thanks in advance. Much appreciated.
-
I still don't understand.:(( I am using codebehind. And initially i can fetch one data from the gridview to another webform and display it in the label. I want to experiment and fetch two datas from the gridview to another webform and display it in the label. And another webform at the page load,
Label1.Text = Request.QueryString["Stud_Admin"];
How can I fetch the Stud_Name as well and display it in Label2.text? thanks in advance. Much appreciated. -
I still don't understand.:(( I am using codebehind. And initially i can fetch one data from the gridview to another webform and display it in the label. I want to experiment and fetch two datas from the gridview to another webform and display it in the label. And another webform at the page load,
Label1.Text = Request.QueryString["Stud_Admin"];
How can I fetch the Stud_Name as well and display it in Label2.text? thanks in advance. Much appreciated. -
Well, the explanation in MSDN is clear enough: +
DataNavigateUrlFields="Stud_Admin,Stud_Name"
(seperated by comma) +DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={0}"
(the parameters in the url are seperated by the&
)Thanks many-many.
minhpc_bk wrote:
+DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={0}" (the parameters in the url are seperated by the &)
Though this should be right, DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={1}"
thanks in advance. Much appreciated.
-
Thanks many-many.
minhpc_bk wrote:
+DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={0}" (the parameters in the url are seperated by the &)
Though this should be right, DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={1}"
thanks in advance. Much appreciated.
-
:mad: I solved and solved, luckily I can solved. GOOd one over there! :laugh:
please be careful newbies. haha.