Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid hyperlink to new page/new datagrid 1

Status
Not open for further replies.

LucasH

IS-IT--Management
Oct 28, 2003
93
US
Hi all,

I am working on a datagrid on weborm1.aspx, with a hyperlink column passing the record ID column along with the url like so:


I have a datagrid on webform2 that I want to use the id passed from webform1.aspx as the selection in my SQL statement.

I am confused as to how I call that id that was passed. I see that I can assign the id to a variable in code in the PageLoad event but how do use that variable in a SQLdataadapter which loads the dataset which loads the new datagrid. I am thinking I have to re-fill the dataset with a new SELECT statement but am having trouble doing it. Any suggestions?
 
>>I am thinking I have to re-fill the dataset with a new SELECT statement but am having trouble doing it

thats the best way to do this, pass the id in the SQL, i am not an expert in datasets but i think they have sorting and searching options.

a search on google could get u better results...

Known is handfull, Unknown is worldfull
 
yeah, make a method to in a DataLayer Class that receives an id parameter and returns a DataSet. Then when you need it just call that method and pass it a ds.

Another possibility is to retreive all the data and cache it. This is of course if the database table doesn't contain alot of records because your initial hit on the DB would be large.
 
LucasH ,
see the below thread..
thread855-1166232

I just explained to someone else how to pass the hyperlink value to another form.

 
dvannoy,

Thanks, I got it working now. I was real close and your post pointed me in the right direction.

Lucas

What I did was to pass the parameter from my original grid using a hyperlink column and passing the id field in the URL field, then made the URL format string
In the resulting webform2.aspx pageload event, I grabbed the id with

Dim id As String = Request.QueryString("id")

then edited the select statement for my dataadapter to the following:

Me.SqlSelectCommand2.CommandText = "SELECT Name,Address FROM People WHERE (ID = " & id &")"

Then refilled the dataset (which my datagrid was based on):

MyDataAdapter.Fill(MyDataSet)
MyDataSet.DataBind()

Simple, really. Thanks a ton.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top