Arrrrgghhh!! HELP!<BR><BR>I am learning ASP .NET and I've been breaking my head for hours trying to figure out a good solution to this problem without any luck. I will send USD $25 via PayPal to the person who comes up with the best solution for this -- Make sure you leave your email address!<BR><BR>Here's what I am trying to do:<BR><BR>I am using a repeater control to display a list of products from a database. Each product has a set of options which I want to display in a drop down list next to the product name. For example: Product = T-Shirt, Options = Small, Med, Large. <BR><BR>Both the product and the individual options will have a unique ID. Below each product listing, there will be a "select" link (or button) that will re-load the page with the product ID and selected option ID as parameters (e.g., testlist.aspx?productid=xx&optionid=yy).<BR><BR>------------------------------------------------<BR>Name: T-Shirt<BR>Options: (drop down list of options)<BR>[Select Link]<BR>------------------------------------------------<BR>Name: Pen<BR>Options: (drop down list of options)<BR>[Select Link]<BR>------------------------------------------------<BR>...<BR><BR>The products and options are stored in two separate tables on a SQL server (tblProducts & tblOptions). Each product is assigned an OptionGroup field which ties it to the options table. The options table define several options, categorized by the field OptionGroup. Thus for each product, there will be at least one or more options based on the optionGroup associated with that product.<BR><BR>tblProducts:<BR>-----------<BR>ProdID ProdName OptionGroup<BR>1 T-Shirt Sizes<BR>2 Pen Colors<BR><BR>tblOptions:<BR>-----------<BR>OptID OptionGroup OptionName<BR>1 Sizes Small<BR>2 Sizes Med<BR>3 Sizes Large<BR>4 Colors Red<BR>5 Colors Blue<BR><BR><BR>Problem #1: How do I efficiently bind this data into the repeater control? Ideally I want to execute a single stored procedure to get the data and bind it, but if it takes two stored procedures (to query each table) that's ok. I have played with the OnItemDataBound event for the repeater with some success, but it still leaves me w/out a solution to the next problem...<BR><BR>Problem #2: Once the data is bound to the repeater control and each individual drop down list, how do I build the "Select" link for each product listing? The link must be in the form: "testlist.aspx?productid=XX&optionid=YY", where YY is the option ID for the user *SELECTED* item. So, I guess if the user changes the option selection, the page will postback (preserving state) and the "Select" link will be rebuilt with the selected option id from the list. Another alternative to this problem would be to use a form post (GET method), but how do i go about it so it only posts data for the selected item and not the whole page?<BR><BR><BR>Here's some test code snippets I've written to work on this. Please note that you will have to create the SQL tables and stored procedure to use this code:<BR><BR>testlist.aspx:<BR>--------------<BR><form id="Form1" method="post" runat="server"><BR><asp:repeater id="repList" runat="server"><BR><itemtemplate><BR><p>Name: <%# DataBinder.Eval(Container.DataItem,"ProductName") %><br /><BR>Options: <asp:dropdownlist ID="ddlOptions" Runat="server"></asp:dropdownlist></p><BR><p><a href=http://aspmessageboard.com/archive/index.php/'testlist.aspx?id=<%# DataBinder.Eval(Container.DataItem,"ProductID") %>&optionid=BIND-ID-HERE'>Select</a></p><BR></itemtemplate><BR><separatortemplate><BR><hr><BR></separatortemplate><BR></asp:repeater><BR></form><BR><BR>testlist.aspx.vb:<BR>-----------------<BR><BR>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR><BR> repList.DataSource = GetList()<BR> repList.DataBind()<BR><BR>End Sub<BR><BR>Private Function GetList() As SqlClient.SqlDataReader<BR><BR> Dim sqlConn As SqlClient.SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))<BR> Dim sqlCmd As SqlCommand = New SqlCommand("spGetList", sqlConn)<BR> sqlCmd.CommandType = CommandType.StoredProcedure<BR> sqlConn.Open()<BR> Return sqlCmd.ExecuteReader(CommandBehavior.CloseConnecti on)<BR><BR>End FunctionOk short, general answers to this. If you can't figure it out or need more detail after you try, post again and we'll see what we can do.<BR><BR>1) It sounds like you should be able to pull all of the data in a single query. The dataset will be larger than if you pulled from each table, but you can do it. The way I'd do it is create a dataset with both tables in it (VS.NET has a wizard for this, it's really easy), then customize it to use whatever stored procedures you want (or use the default). Then you set the datasource of the repeater to yourDataSetInstance and just use Databinder.Eval with each item.<BR><BR>2) For this second part, I think what you should look at is firing the click as an event, instead of trying to build the link. There's an "OnItemCommand" which you can fire and then have access to all the controls as they were when the user clicked. From there, just build the new page string and redirect the user to that url. Elsewise, you could just use client side javascript to do it. You can easily find the script to do this on any basic javascripting site.Hi,<BR><BR>Thanks for the info!...<BR><BR>But, I guess I need the long detailed response. I am still unclear on how to bind a two-table dataset (products and options) to the repeater (products) and its child control (options) while maintaining the relationship (products.optiongroup = options.optiongroup)<BR><BR>I've tried to code it several ways (within my limited knowlewdge of ASP .NET) without any luck. Can you provide some sample code to go by? I posted the code for the repeater/dropdown on the original message.<BR><BR>Thanks in advance!<BR>cl<BR><BR>Ok here's the slightly longer explanation. I sure hope you have VS. What you need to do is create the relationship between the tables in the dataset. So you create your dataset with the products and the options table, then create the relationship between the two tables in the dataset. In VS all you need to do is drag one key field and drop it on the other.<BR><BR>Then the easiest way to populate it is to create a component for filling the dataset, and drag a data adapter for each table into the component. Also add an instance of the dataset. VS writes about 99% of the code for you with this method. One you have all of these items in the component, you can right click on one of the data adapters and choose "Preview Data". It will bring up the dataset and the data adapters. The important thing here is to make sure you fill from the master table first. If you try to fill from the "many" side of a relationship first, you'll get an error saying that you violated a relationship.<BR><BR>So once you have the component built you can just instantiate the dataset and call your loader method. Then when you iterate through the master table, the child records (options in your case) that are associated with it are already there in the dataset.<BR><BR>Ok as mentioned most of everything you need to code is done by VS. But here's the little bits of code that you would need to enter yoruself.<BR><BR>In the loader component:<BR><BR>Public Function LoadData() As DataSet<BR> ProductsDA.Fill(ProductDS1)<BR> OptionsDA.Fill(ProductDS1)<BR> Return ProductsDS1<BR>End Function<BR><BR>Here ProductsDA and OptionsDA are the data adapters that you dragged into the component. ProductDS1 is an instance of your dataset that you dragged into the component.<BR><BR>In the page you want to use the dataset:<BR><BR>Dim myLoader As New siteLoader()<BR>ProductDS1 = myLoader.loadData()<BR>DataBind()<BR><BR>ProductDS1 is created by dragging your dataset onto the page.