Datagrids and hyperlinks to more data.

  • Thread starter Thread starter Tmuld
  • Start date Start date
T

Tmuld

Hello,

I am using a flat file database that has been imported to SQL Server
2000. So it is a DB with one table.

What I want to do is display 3 of the 30 fields on an .aspx screen.
One of the 3 fields would have a hyperlink. Upon clicking that
hyperlink the remaining 27 fields of that particular record would be
displayed - so more detail per record can be displayed.

Right now - I have created a datagrid that is populated by an sql
statement which pulls the 3 fields in.

What is the best way to put in the hyperlink on a field? Then the
code to display more data?

For example (name would would have the hyperlink designated by the
'---')

Right now it would show this:


Name Address Sex

Dave House M
----
Ben Apt M
---
Sue House F
---

On clicking the ---- by Dave it would reveal:

Name Address Sex Phone Cable Utilties Washer Stove Furnished
Price ...(20 more fields)

Dave House M 555555 $10 Electric Maytag Gas Partly
$1000 ... (20 more fields shown)


Suggestions on how to get started?
Tutorial, code example or website?

Thanks,

Tmuld
 
Hi,

Why don't you create a page called, say, "details.aspx". Then add a
HyperlinkColumn to your data grid and set the
"DataNavigateUrlFormatString" attribute to "details.aspx?id={0}" and
also set the DataNavigateUrlField attribute to "fldID", or whatever your
primary key field is.

So it'll look something like this:

---
<asp:HyperlinkColumn
HeaderText="More Details"
DataNavigateUrlField="fldID"
DataNavigateUrlFormatString="details.aspx?id={0}"
Text="Show Details" />
---

It might be worth having a look at the HyperlinkColumn class in the
framework documentation and getting familiar with it's properties.

Then, in details.aspx you would display all of the information for the
user ID passed in the URL. You can get the ID variable from the url by
accessing the Request.QueryString collection.

That's how I would do it personally.

Regards,
-Adam.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top