?
Solved

DataList inside a ListView - passing parameter

Posted on 2009-02-13
5
Medium Priority
?
1,224 Views
Last Modified: 2012-05-07
I have a DataList inside a ListView.  The ListView renders a list of products.  The nested DataList lists out a number of cooresponding options related to the product.  I have a SqlDataSource that selects product options based on product ID.  How can I get the DataList's datasource to get the corresponding product id as the select parameter?  
<asp:ListView ID="lvProducts" runat="server" DataSourceID="sqlProdByCat" 
                        ItemPlaceholderID="phImgProd" ondatabound="lvProducts_DataBound" 
                        onitemcommand="lvProducts_ItemCommand" 
                        onitemdatabound="lvProducts_ItemDataBound" DataKeyNames="PROD_ProdID">
                        <LayoutTemplate>
                            <table cellpadding="0" cellspacing="0" border="0" width="0">
                                <tr>
                                    <td><asp:PlaceHolder ID="phImgProd" runat="server"></asp:PlaceHolder></td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <td><asp:ImageButton ID="imgProduct" runat="server" 
                                ImageUrl='<%#Bind("PROD_LgImg") %>' CommandName="Detail" 
                                CommandArgument='<%#Bind("PROD_ProdID") %>'/><br />                                
                            <div class="options" 
                                style="text-align: center;">
                                <asp:DataList ID="dlActions" runat="server" 
                                    DataSourceID="sqlActionsByProd" 
                                    RepeatLayout="Flow" RepeatDirection="Horizontal">
                                    <ItemTemplate><strong>
                                        <asp:LinkButton ID="lnkAction" runat="server" 
                                            Text='<%# Bind("ACTN_ActionDesc") %>' 
                                            CommandName="tab" CommandArgument='<%# String.Format("{0}&{1}", DataBinder.Eval(Container.DataItem, "PROD_ProdID").ToString(), DataBinder.Eval(Container.DataItem, "TABS_TabID").ToString()) %>'>
                                        </asp:LinkButton></strong>
                                    </ItemTemplate>
                                    <SeparatorTemplate>&nbsp;&nbsp;  </SeparatorTemplate>
                                </asp:DataList></div></td>
                        </ItemTemplate>
                    </asp:ListView>

Open in new window

0
Comment
Question by:centdevs
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 23635949
in the sqlActionsByProd datasource, set the product parameter has a control parameter and the ListView has the control.
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 23636013
sorry,
instead, move the sqlActionsByProd datasource inside the <ItemTemplate> of the listview and set the parameter s default value using '<%#Eval("PROD_ProdID") %>'/

0
 
LVL 18

Accepted Solution

by:
David Robitaille earned 2000 total points
ID: 23636052
0
 

Author Comment

by:centdevs
ID: 23637321
Do I have to do anything programmatically?  I am currently getting an error:

"Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.Parameter does not have a DataBinding event."

And if I switch the select parameter to a control parameter I get the same type of error.
0
 

Author Comment

by:centdevs
ID: 23637438
I just needed to move the sql data source to inside the listview rather than the datalist and use the control parameter.  Thank you!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question