papa_k Posted September 17, 2003 Posted September 17, 2003 i want to display data in a table on a asp.net web page. i have done his using the old asp using a response.write("") in a loop to create the table rows. what is the best way to do this in ASP.net? Quote without time nothing ever ends
Moderators Robby Posted September 17, 2003 Moderators Posted September 17, 2003 Are you willing to use a datagrid, or do you want to stick with html tables? Quote Visit...Bassic Software
papa_k Posted September 17, 2003 Author Posted September 17, 2003 I can now use the table form. i just havent had a chance to note it in this call yet. i have managed to get the table to load when the page is created. that is not a problem. within that table that i dynamically create i can have one of the cell values set as a hyperlink that can again be dynamically created so that it contains a query string. when this is then clicked on the next page that i need to open can wonder off with the query string value and get the data from my database. the only problem i have now is the one i posted back on http://www.xtremedotnettalk.com/t76875.html i need to be able to get a complex string from another page, and using the query string method is not sufficient because it is possible to enter anything (including anything like ? and & which may cause a problem) Is is possible to lift information from one aspx page and import it into the load of the following aspx page? this is something that i have posted before i know, but this time i really think that i am going to have to be able to send informaiton like the old ASP post method. i just need to know how to do it. you see i would have been able to type request("the_variable_i_need") and it would have pulled it across. any thoughts?? Quote without time nothing ever ends
Moderators Robby Posted September 17, 2003 Moderators Posted September 17, 2003 One way is this.... 'page that contains the data (this class would be named SendingPage) Public ReadOnly Property SomeString() As String Get Return SomeMemberVariable End Get End Property 'page that requests the data Private otherPage As SendingPage '(the name of the previous page) Private Sub Page_Load(....) If Not IsPostBack Then otherPage = CType(Context.Handler, SendingPage) End If 'now you can use the value anywhere on this page.... dim s as string = otherPage.SomeString End Sub Any object can be passed using the above example. Quote Visit...Bassic Software
papa_k Posted September 18, 2003 Author Posted September 18, 2003 I have a problem with this. Basically it doesnt work when i try to do it. I am not sure that this is the problem. If i am right, i just place this code within the page i am 'sending' the data from...it just goes within the code right? 'page that contains the data (this class would be named SendingPage) Public ReadOnly Property SomeString() As String Get Return SomeMemberVariable End Get End Property This code DOES seem to the be the problem though. I think it might just be the way that i am using it. 'page that requests the data Private otherPage As SendingPage '(the name of the previous page) Private Sub Page_Load(....) If Not IsPostBack Then otherPage = CType(Context.Handler, SendingPage) End If 'now you can use the value anywhere on this page.... dim s as string = otherPage.SomeString End Sub Private otherPage As SendingPage '(the name of the previous page) where does the above piece go within the page that i am opening (outside of any subs?) when i run it the problem i have is to do with the cast. it says that it is an invalid cast? anythoughts? Quote without time nothing ever ends
Moderators Robby Posted September 18, 2003 Moderators Posted September 18, 2003 Yes this should go outside of a sub, usaully near the top of the page Private otherPage As SendingPage keep in mind that SendingPage is the class name of the previous page Quote Visit...Bassic Software
papa_k Posted September 19, 2003 Author Posted September 19, 2003 still no joy. page1 code. i have the code within the class. it is outside of any other functions, it is stand alone within the class. page2 code. i have the private otherpage as page1 above the load of the page. it is not part of any sub but is within the class. i have the other code If Not IsPostBack Then otherPage = CType(Context.Handler, query) End If within the load of page2. when i compile the pages i do not get an error. when i run the page though i do get an error. it says "Specified cast is not valid". this error occurs when i enter the page 2. and must be to do with the CType that i have there. this is the only cast that exists on the page. robby / anyone have an example of this code working? i dont know whats up with what i am doing. i cant see anything wrong. Quote without time nothing ever ends
Moderators Robby Posted September 19, 2003 Moderators Posted September 19, 2003 Follow my example and it will work. What's query? That should be the class name of the previous page. Quote Visit...Bassic Software
papa_k Posted September 19, 2003 Author Posted September 19, 2003 Follow my example and it will work. What's query? That should be the class name of the previous page. query is the name of the class on the page (page1). i have found another link. The code is very simliar as yours. This other code puts it in the HTML of the page though, not in the aspx.vb should i put it in there? Quote without time nothing ever ends
papa_k Posted September 19, 2003 Author Posted September 19, 2003 ahblahdeehell... I have solved the problem. I had to use server.transfer("pagename.aspx") for the movement between the pages! i kept gettin that bloddy cast problem that means absolutely nothing when you know how to fix the problem! you must use the above instead of using response.redirect("pagename.aspx") i am sorry if this something that was obvious robby and to others. thanks for you help with this one though, got there in the end. Papa. *****CLOSED***** Quote without time nothing ever ends
Moderators Robby Posted September 19, 2003 Moderators Posted September 19, 2003 I assumed you were using Server.Transfer() because I pointed this out in your other thread here ... http://www.xtremedotnettalk.com/showthread.php?s=&threadid=76875 Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.