.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 23rd, 2009, 03:10 PM
garmon648 garmon648 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 4 garmon648 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 14 sec
Reputation Power: 0
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!

Reply With Quote
  #2  
Old October 23rd, 2009, 04:26 PM
rclark's Avatar
rclark rclark is offline
I do .NET for a living
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Sep 2003
Location: Florida
Posts: 1,435 rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 20 h 37 m 13 sec
Reputation Power: 157
Quote:
Originally Posted by garmon648
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!


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)

Reply With Quote
  #3  
Old October 23rd, 2009, 05:07 PM
garmon648 garmon648 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 4 garmon648 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 14 sec
Reputation Power: 0
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:
Originally Posted by rclark
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.

Reply With Quote
  #4  
Old October 23rd, 2009, 05:16 PM
rclark's Avatar
rclark rclark is offline
I do .NET for a living
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Sep 2003
Location: Florida
Posts: 1,435 rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 20 h 37 m 13 sec
Reputation Power: 157
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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > ASP.Net/General - Passing Variables to DataGrids


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek