Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Using Server.Transfer with HyperLinkColumn in a datagrid

Reply
Thread Tools

Using Server.Transfer with HyperLinkColumn in a datagrid

 
 
Elton Wang
Guest
Posts: n/a
 
      03-15-2005
Hi Jason,

Without more detailed info, it's hard to say what's wrong
in you application.

Personally, I don't think it will cause trouble to pass
any data to the second page without using Server.Transfer.

Elton Wang


>-----Original Message-----
>Hello all,
>I am trying to pass page properties between two pages and

the first page
>contains a datagrid loaded dynamically from a data access

and the second
>page needs one item from the query string and the

provided properties from
>the previous page. I am getting an error from the second

Page_Load method
>during the loading of the properties of the previous

page. The error is
>'Specified cast is not valid' which is consistant with an

error that occurs
>when you do not use Server.Transfer( ... ) to access the

second page ( I
>think this is the reason for the error ). My question is

do you think this
>is the source of my error and if so is there a way to

control how the page
>is transfered? I am developing using C# as code behind to

aspx.
>
>Thanks...
>
>--
>Message posted via http://www.dotnetmonster.com
>.
>

 
Reply With Quote
 
 
 
 
Elton Wang
Guest
Posts: n/a
 
      03-15-2005
First of all, you should understand the web application is
completely different from windows application. It's so
called stateless that means once you move from one page to
another page the first page is disappeared. You can't
refer to it and of course, can't get any data from it.
When you go back to the first page, it actually re-
initializes a new instance.

In order to transfer data between pages within an
application, you can use ApplicationState, SeesionState,
ViewState, or Cookie to save data in these objects, and
then share the data in different pages. In your case, you
can use SessionState to save data in page1. Then in page2
retrieve the data from SessionState.

To save data to SessionState:
Session("keyName") = obj;

To retrieve data from SessionState:
ObjectType obj = (ObjectType)Session("keyName");

HTH

Elton Wang


>-----Original Message-----
>Here is an example of my code and error location.
>The full code is much to large to post so here is an

abstract.
>
>Page1.aspx.cs
>
>public string Property1
>{
> get
> {
> return prop1;
> }
>}
>
>public string Property2
>{
> get
> {
> return prop2;
> }
>}
>
>page1.aspx
>
>populate a datagrid via data access and
><Columns>
> <asp:HyperLinkColumn DataNavigateUrlField="LocationID"
> DataNavigateUrlFormatString="page2.aspx?ID=

{0}"
>DataTextField="LocationName" HeaderText="Store">
> <HeaderStyle Font-Size="11px" Font-

Bold="True"></HeaderStyle>
> <ItemStyle Font-Size="11px" Wrap="False"
> HorizontalAlign="Left"CssClass="blueLink"
> VerticalAlign="Top"></ItemStyle>
> </asp:HyperLinkColumn>
>
>bla bla....
></Columns>
>
>page2.aspx.cs
>//define prop1 and prop2 as strings
>
>private void Page_Load
>(object sender, System.EventArgs e)
>{
> //create instance of source web form
> page1 p1;
>
> //get reference to current handler instance
> p1 = ( page1 )Context.Handler; <-------Here

is where the error
>ocurrs
> prop1 = p1.Property1;
> prop2 = p1.Property2;
>}
>
>I hope this is enough to work with.
>
>--
>Message posted via http://www.dotnetmonster.com
>.
>

 
Reply With Quote
 
 
 
 
Elton Wang
Guest
Posts: n/a
 
      03-15-2005
Of course, it's fine if you use query string to pass
parameters to second page.

In your case, you can use

page2.aspx?prop1=p1Value&prop2=p2Value

to access page2 from page1.

In page2, use

string p1 = Request.QueryString.Get("prop1");
string p2 = Request.QueryString.Get("prop2");

to retrieve those values.

HTH

Elton Wang


>-----Original Message-----
>I want to refer you to a page that explains what I am

trying to do here and
>it is located @

http://www.dotnetbips.com/displayarticle.aspx?id=79
>I work for a large company and we have rules in place

governing what I can
>and cannot use such as session state state management. We

have to use a
>component that requires the use of a database and for

what I am doing that
>is much more overhead then I want at this time, but if I

have to I will use
>it. I hope this explains my purpose.
>
>--
>Message posted via http://www.dotnetmonster.com
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variables in query string in the HyperLinkColumn of a datagrid aparnasinha26@yahoo.com ASP .Net 2 05-18-2005 06:02 AM
Datagrid - HyperLinkColumn Rob Meade ASP .Net 0 08-09-2004 10:54 AM
Can't apply CSS class to DataGrid's HyperlinkColumn? =?Utf-8?B?RGF2ZQ==?= ASP .Net 1 02-27-2004 04:31 PM
Determine the index of the datarow in the datagrid when using hyperlinkcolumn debiken ASP .Net Datagrid Control 0 11-17-2003 10:38 PM
Adding Multiple values to DataGrid HyperLinkColumn dynamically vtreddy ASP .Net 0 11-06-2003 04:10 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57