473,320 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

best approach to use

J
I'm a bit new to asp.net and I'm investigating the best approach to this:

I have a contact table that includes stuff like Name, address, phone, etc.
Because each contact can contain multiple 'product' values, I have a
separate product table that has a many-to-one relationship with the contact
table. I also have an 'industry' table that also has a many-to-one
relationship with the contact table.

1. I would like to have a page that has a search box, and displays results
with summary info.

2. By clicking one of the records in the summary results, another page that
contains the contact edit screen comes up. This will include an 'product'
section and an 'industry' section which has check boxes to select all the
products or industries for this particular contact (looking up the values in
lookup tables).

Ideally, I could leverage asp.net controls as much as possible but sometimes
I seem to beat myself up trying go get them to do what I want them to do. I
can very quickly and easily do step number 1 by using a databound GridView
control. Yet it's not intuitive to my how to make the last name a link to
an edit page. Accomplishing number 2 seems to fall apart with the
many-to-one relationship data.

Any ideas on how to approach this would be appreciated.
Jan 7 '08 #1
2 1084
A real quick answer to one of your questions. How do you set the last
name to a link that will go to an edit page...

First, declare the OnDataBound property for the gridview. Then in the
code behind, in the OnDataBound function, check for the incoming data
to be an actual row of data and not a header or footer. Then when
inside that block, use the eventarg to set the column that holds the
last name as a link to a seperate page that processes the editing.

Here is some sample code:

IN THE ASPX FILE:

<asp:GridView ID="GridView1" runat="server"
OnDataBound="GridView1_RowDataBound">
</asp:GridView>

IN THE CODE BEHIND:

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
// Make sure we are processing a DataRow
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Get last name, 0 is the first cell (column) in the
gridview, if you wanted a different cell, enter a different number
string lastName = e.Row.Cells[0].Text;

// Change last name to a link to edit page
e.Row.Cells[0].Text = "<a href='edit.aspx?lastName="+
lastName + "</a>";
}
}

Of course, going off of this, you could pull the users id and pass
that to the edit page in case there are multiple last names. You
would just add that inside the RowDataBound function.

Then in the edit page, you will have to do some processing to get the
one-to-many relationship to work, but it's definately do-able!

Have fun!
Jan 7 '08 #2
It sounds to me that you want to have associative or "junction" tables.

CONTACT CONTACT_PRODUCT PRODUCT
========= ============= =======
CONTACT_ID CONTACT_ID PRODUCT_ID
PRODUCT_ID

The Contact_product table will have multiple entries for the same contact,
each one "pointing" to a product ID for that contact_ID in the PRODUCT table.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"J" wrote:
I'm a bit new to asp.net and I'm investigating the best approach to this:

I have a contact table that includes stuff like Name, address, phone, etc.
Because each contact can contain multiple 'product' values, I have a
separate product table that has a many-to-one relationship with the contact
table. I also have an 'industry' table that also has a many-to-one
relationship with the contact table.

1. I would like to have a page that has a search box, and displays results
with summary info.

2. By clicking one of the records in the summary results, another page that
contains the contact edit screen comes up. This will include an 'product'
section and an 'industry' section which has check boxes to select all the
products or industries for this particular contact (looking up the values in
lookup tables).

Ideally, I could leverage asp.net controls as much as possible but sometimes
I seem to beat myself up trying go get them to do what I want them to do. I
can very quickly and easily do step number 1 by using a databound GridView
control. Yet it's not intuitive to my how to make the last name a link to
an edit page. Accomplishing number 2 seems to fall apart with the
many-to-one relationship data.

Any ideas on how to approach this would be appreciated.
Jan 7 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Navin | last post by:
HI, Guys There has been a lot of Ways to use paging in asp 1>Recordset approach -where whole records are pulled at client side... and then only the records which are needed are filtered.. and...
6
by: Paul | last post by:
Hi. Just trying to find out the best approach as I beleive it might give me problems later on down the road. I have an ASP.NET application which references a shared database class which...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: Andy Britcliffe | last post by:
Hi I'm faced with the situation where I could have a single physical file that could contain multiplie XML documents e.g file.txt contains the following: <?xml version="1.0"...
1
by: milesm | last post by:
I've spent the last 3 hours reading various MSDN articles, other site articles and news group postings and was wondering what the best approach to my situation would be since I'm unable to come up...
4
by: David Pinx | last post by:
Greetings, I will be developing an application that will have two versions, a web application to be deployed at the client side and a windows application. The question is, what would be the...
4
by: Ned Balzer | last post by:
Hi all, I am pretty new to asp.net; I've done lots of classic asp, but am just beginning to get my mind wrapped around .net. What I'd like to do is include some code that tests if a user is...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
6
by: bill | last post by:
I am about to start on a module that will accept a location from a user, use Google geolocation services to get the lat/lon and then compute the distance from the site visitor to about 100 kennels...
5
by: gw7rib | last post by:
I'm writing a program which has "notes" - these can appear on the screen as windows with text in. It is possible to create an "index note" - at present, this will contain a list of the titles (or...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.