best approach to use
am 07.01.2008 16:34:54 von Patrice
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.
Re: best approach to use
am 07.01.2008 18:07:51 von younlaot
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:
OnDataBound="GridView1_RowDataBound">
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 = "
Have fun!
RE: best approach to use
am 07.01.2008 18:22:03 von pbromberg
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.
>
>
>