codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Seperate Master / Detail pages  crite at 00:17 on Sunday, November 21, 2004
 

I am just learning ASP.NET and I am trying to create a Master / Detail set-up where I have a list of categories displayed in a DataGrid in my user control and when someone clicks one of the category links they are taken to the products page where all the relevant products are displayed in a DataList. My products page Datalist will retrieve 4 columns from my database products table including an image and also will need to include a link to the Master Products page. Can anyone help me with this, Im using C# and have succesfully created the category links datagrid to go to the Products page but Im having trouble displaying the relevant products in the DataList.
Cheers

  Re: Seperate Master / Detail pages  tgreer at 01:07 on Sunday, November 21, 2004
 

What is your specific problem or error? Is it a .NET Event problem, or a Web Form/Control problem, or is it a database problem?



  Re: Seperate Master / Detail pages  crite at 03:02 on Sunday, November 21, 2004
 

.NET Event problem. I have managed to link the category links to my product detail page which then displays all my products using a DataList but I need to only display the relevant products for the selected category, this is where Im stuck.
Ive linked the categories to the products using:
productDetail.aspx?id={0} in the DataGrid. Now I need to add some C# that displays only the relevant products for the selected category by linking the DataGrid (in the user control) to my DataList on my products page.

  Re: Seperate Master / Detail pages  t.manojp at 10:53 on Tuesday, November 23, 2004
 

hi,

if u have assigned a DataKeyField to ur datagrid u will get the value assigned to it by id={0}, now u can access this value with Request.Querystirng["id"] and with that id u cag get the assosiated product for that category.

Manoj

  Re: Seperate Master / Detail pages  crite at 11:34 on Tuesday, November 23, 2004
 

thanks for reply, still a bit stuck. Here's my C# for products detail page:

private void Page_Load(object sender, System.EventArgs e)
{
int catID = 0;
if (Request.QueryString["CategoryID"] == null)
{
Response.Redirect( "/forum/default.html" );
}
else
{
catID = Convert.ToInt32Request.QueryString "CategoryID"]);
}
Label1.Text = catID.ToString();
sqlDataAdapter1.Fill( dataSet1 );
DataList1.DataSource = dataSet1;
DataList1.DataBind();
sqlConnection1.Close();
}

Put Label in to test and it displays CategoryID, obvoiusly missing a bit of code that places the relevant products in my DataList. Any help would be great, cheers.

  Re: Seperate Master / Detail pages  tgreer at 15:09 on Tuesday, November 23, 2004
 

I'm still confused.

There are two data models you can use with ASP.NET. One is to pull everything you need from the database, and store it in ADO.NET DataSets. DataSets are complex objects, in fact, they are miniature in-memory databases, with multiple tables and relationships.

That appears to be what you're trying to do, pull a Master table and a Detail table across into separate DataTables, build a relationship in the DataSet, etc.

Don't do that. It's way too memory intensive.

Instead, you can use DataReaders. A DataReader is a single read-only, forward-only recordset that does NOT persist. The idea is, go in, get what you want, process the results, and get out.

So for your scenario I would suggest that you create a query, or better yet, a stored procedure, for each process. One to get the Master records, and a second to get the Detail records.

When a user clicks a Master row, get the data from that row, and pass it as a parameter to your second query.

Are you with me so far? Let's stop here and see if you have any questions.









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Print and print preview file on the website without using the File - Print on the IE
•  Re: ASP.NET web controls
•  Re: JavaSript Problem In Mac Safari Browser
•  Re: DHTML div positionning Problem
•  Convert script to NS6 compatible - Please Help!
•  Print .doc file from the website using System.Diagnostics.Process
•  Re: Fullscreen code
•  Re: iframe targeting
•  Excel n ASP


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005