Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8302393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:16:49+00:00 2026-06-08T17:16:49+00:00

i have two tables which stores items and itemsizes, a item will have different

  • 0

i have two tables which stores items and itemsizes, a item will have different sizes. i am trying to display the itemsizes for the item in a dropdownlist with in a datalist. my html is as below

<asp:DataList ID="dlstCartItems" runat="server" RepeatDirection="Horizontal" RepeatColumns="5"
                    Width="580px" ForeColor="Blue" DataKeys="ItemCode"
                    onitemdatabound="dlstCartItems_ItemDataBound">
                    <ItemTemplate>
                        <table cellpadding="0" cellspacing="0" style="border: Solid 2px #eeeeee;">
                            <tr>
                                <td align="left" style="width: 180px;">
                                    <a href="Videos.aspx?vid=<%# Eval("itemid") %>">
                                        <img src="images/Gallery/<%# Eval("imagename") %>" alt="Image" height="120px" width="185px"
                                            style="border: 0;" />
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 180px;" align="left">
                                    <table>
                                        <tr>
                                            <td>
                                                Name:
                                            </td>
                                            <td>
                                                <a href="Videos.aspx?vid=<%# Eval("itemid") %>">
                                                    <asp:Label ID="lblVideoName" runat="server" Text='<%# Eval("name")%>' ForeColor="#06C"></asp:Label>
                                                </a>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Author:
                                            </td>
                                            <td>
                                                <a href="Videos.aspx?Authorid=<%# Eval("itemid") %>">
                                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("thm") %>' ForeColor="#06C"></asp:Label></a>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Technology:
                                            </td>
                                            <td>
                                                <a href="Videos.aspx?Techid=<%# Eval("itemid") %>">
                                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("itemcode") %>' ForeColor="#06C"></asp:Label></a>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>

                                    <asp:DropDownList ID="ddlAvailableSizes" runat="server"  >
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                    <%--<AlternatingItemStyle BackColor="Silver" />--%>
                    <ItemStyle BackColor="#eeeeee" />
                </asp:DataList>

This is my bind method

 var query = (from b in db.CR_CartItems
                         join c in db.CR_CartItems_Sizes on b.ItemCode equals c.ItemCode
                         join k in db.CR_ScrollingMenus on b.ThemeID equals k.MenuID

                         where b.status == true
                         orderby b.updatedat descending
                         select new
                         {
                             itemid = b.Itemid,
                             imagename = b.galleryimg,
                             itemcode = b.ItemCode,
                             thm = k.DisplayName,
                             name = b.posterName

                         }).Distinct();
            foreach (var q in query)
            {

                var query1 = from b in db.CR_CartItems_Sizes
                             join c in db.CR_CartItems on b.ItemCode equals c.ItemCode
                             where b.ItemCode == q.itemcode
                             select new
                             {
                                 b.SizeDesc,
                                 b.ItemCode
                             };

                foreach (DataListItem li in dlstCartItems.Items)
                {
                    DropDownList list = (DropDownList)li.FindControl("ddlAvailableSizes");
                    list.DataSource = query1;
                    list.DataTextField = "SizeDesc";
                    list.DataValueField = "ItemCode";
                    list.DataBind();
                    list.Items.Insert(0, "Available Sizes");
                }


            }
            dlstCartItems.DataSource = query;
            dlstCartItems.DataBind();
        }

i have set up a break point at the foreach loop and checked, it is not entering the loop. any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:16:50+00:00Added an answer on June 8, 2026 at 5:16 pm

    You have to handle the DataList.ItemDataBound event:

    Assuming you are binding your DataList like: (or similar, using a data source control)

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.dl.DataSource = GetDataSource();
            this.dl.DataBind();
        }
    }
    

    Then your ItemDataBound handler would look like:

    protected void dl_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            var myDropDownList = e.Item.FindControl("YourDropDownListID") as DropDownList;
            int currentItemID = int.Parse(this.dl.DataKeys[e.Item.ItemIndex].ToString());
    
            myDropDownList.DataSource = GetDDLDataSource(currentItemID);
            myDropDownList.DataBind();
        }
    }
    

    Finally make sure to register the event in the DataList markup

        <asp:DataList ID="dl" runat="server" 
            onitemdatabound="dl_ItemDataBound"
            DataKeyField="Your_Row_ID"
        >
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables which are used to store details of different types of
I have two tables which have some transactional stuff stored in them. There will
I have two different tables from which I need to pull data blogs which
I currently have two tables in which stores the attendances of a student in
I have two tables, one which stores articles and the number of votes it
I have two tables which looks something like this Table Queue int ID; string
I have two tables which I want to join together using a left outer
I use Hibernate with Java. I have two tables which are associated with foreign
I have two or more tables which hold values under the same column name.
I have two tables Department Professor in which Department has an attribute called HeadID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.