|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ASP.Net/General - Passing Variables to DataGrids
I have a data grid on one page that is bound to an SQL query. Select is enabled on the grid. I would like to navigate to a second page when the Select button is clicked. I would like to populate a details view on the second page using an account number field in the data grid on the first page. I am very new to ASp.net and I just cannot figure out how to do this. Any suggestions??
Thanks! |
|
#2
|
||||
|
||||
|
Quote:
Use a hyperlink field: Code:
<asp:HyperLinkField DataTextField="PartNumber" HeaderText="Part Number" DataNavigateUrlFields="PartNumber" DataNavigateUrlFormatString="/PartsDetail.aspx?PartNumber={0}" Target="_blank" />
DataTextField = the text that will display as the link DataNavigateUrlFields = The field that will be used in the format string DataNavigateUrlFormatString = the string to format. In this case a URL including the DataNavigateUrlFields which will replace the {0} area of the format string. The Target="_blank" is optional and makes the new page open as a new window rather than replacing the grid page you're on.
__________________
Roger (.NET MCP) |
|
#3
|
|||
|
|||
|
Thanks for the reply. I am assuming I need to reference the field somehow in the query for the new grid or is it a postback somehow??
Quote:
|
|
#4
|
||||
|
||||
|
Not sure what you're asking. The field to pass has to be in the datagrid, but can be a not visible field if you don't want to show it. Once you call the new page, the passed variable is available as a querystring so gather it in the usual way:
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If Not Request.QueryString("PartNumber") Is Nothing Then
_PartNumber = Request.QueryString("PartNumber")
GetDetail(_PartNumber)
End If
End If
End Sub
|
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > ASP.Net/General - Passing Variables to DataGrids |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|