Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Datagrid nested within a datalist is not displaying any data

Posted on 2011-02-15
3
Medium Priority
?
1,174 Views
Last Modified: 2012-05-11
I have a dataset that pulls back the following data:

QuizID      QuizName      BadgeName      BadgesEarned
1      Physical Fitness      Chocolate      0
1      Physical Fitness      Coffee      2
1      Physical Fitness      Fruit      1
1      Physical Fitness      Strawberry      1
1      Physical Fitness      Wheatgrass      0
2      Eating      Chocolate      1
2      Eating      Coffee      1
2      Eating      Fruit      3
2      Eating      Wheatgrass      1
3      Dieting      Chocolate      0
3      Dieting      Coffee      0
3      Dieting      Fruit      0
3      Dieting      Strawberry      0
3      Dieting      Wheatgrass      0

On my aspx page I have the following code:

<asp:DataList id="gvAdminBadingHistory" DataKeyField="QuizID" OnItemDataBound="gvAdminBadgingHistory_ItemDataBound" gridlines="both" runat="server">

<HeaderTemplate>

</HeaderTemplate>

<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "QuizName") %>

<asp:DataGrid runat="server" ID="gvBadges" DataKeyField="QuizID" AutoGenerateColumns="false">
<Columns>
                           
                           <asp:TemplateColumn>
                            <FooterStyle />
                            <HeaderStyle />
                            <ItemStyle />
                        <EditItemTemplate>
                            <!-- child controls -->
                        </EditItemTemplate>
                        <FooterTemplate>
                            <!-- child controls -->
                        </FooterTemplate>
                        <HeaderTemplate>
                            <!-- child controls -->
                        </HeaderTemplate>
                        <ItemTemplate>
                            <ItemTemplate>
                                    <asp:Label ID="lblBadgeName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "BadgeName") %>'></asp:Label>
                                </ItemTemplate>

                        </ItemTemplate>
                </asp:TemplateColumn>
                <asp:TemplateColumn>
                            <FooterStyle />
                            <HeaderStyle />
                            <ItemStyle />
                        <EditItemTemplate>
                            <!-- child controls -->
                        </EditItemTemplate>
                        <FooterTemplate>
                            <!-- child controls -->
                        </FooterTemplate>
                        <HeaderTemplate>
                            <!-- child controls -->
                        </HeaderTemplate>
                        <ItemTemplate>
                            <ItemTemplate>
                                    <asp:Label ID="lblBadgesEarned" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "BadgesEarned") %>'></asp:Label>
                                </ItemTemplate>

                        </ItemTemplate>
                </asp:TemplateColumn>


               
                        </Columns>


</asp:DataGrid>
</ItemTemplate>

<FooterTemplate>

</FooterTemplate>

</asp:DataList>

On my .cs page I have the following code:

        protected void gvAdminBadgingHistory_ItemDataBound(object sender, DataListItemEventArgs e)
        {
           



        }

What code do I need to put inside of the ItemDataBound event so that my datagrid will populate with the BadgeNames and BadgesEarned columns from my dataset for each QuizID?
0
Comment
Question by:jjliu4492
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Expert Comment

by:hiteshgoldeneye
ID: 34903333
Have you binded the datasource for the data list to the dataset you have given here?

Do you get values for Quizname in the datalist, but no values in DataGrid?
0
 

Author Comment

by:jjliu4492
ID: 34910100
Yes I have binded the datasource for the datalist to the dataset.

The datalist populates with the QuizName from the dataset, but the nested datagrid does not populate with the BadgeName and BadgesEarned frmo the dataset.
0
 
LVL 13

Accepted Solution

by:
hiteshgoldeneye earned 2000 total points
ID: 34913302
In your ItemDataBound method you need to call the BindGrid method for the item that is selected, we can grab the data key value from the DataKey collection for the main grid item (e.Item). In your BindGrid method:

    gvBadges.DataSource = getBadge(gvAdminBadingHistory.DataKeys(e.Item.ItemIndex))


please refer the link below for more details
http://p2p.wrox.com/asp-net-1-1/30602-datagrid-nested-datalist-passing-parameters.html
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

718 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