PC Review


Reply
Thread Tools Rate Thread

best approach to use

 
 
J
Guest
Posts: n/a
 
      7th Jan 2008
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.


 
Reply With Quote
 
 
 
 
younlaot
Guest
Posts: n/a
 
      7th Jan 2008
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!
 
Reply With Quote
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      7th Jan 2008
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.
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
What is the best approach? =?Utf-8?B?QW5kcmV3?= Microsoft ASP .NET 0 3rd Mar 2006 08:38 PM
New approach davegb Microsoft Excel Programming 6 6th Dec 2005 04:31 PM
Let try a different approach Blogman Microsoft Outlook Discussion 9 28th Sep 2005 07:45 PM
a more OO approach. chris.millar@voyage.co.uk Microsoft C# .NET 2 13th Feb 2004 03:46 PM
Best Approach? Darin Microsoft C# .NET 5 23rd Sep 2003 08:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:05 AM.