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 992739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:18:53+00:00 2026-05-16T06:18:53+00:00

I have a gridview that displays all trips – within that gridview I have

  • 0

I have a gridview that displays all trips – within that gridview I have a repeater that displays the countries visited during that trip (one to many). My repeater is suppose to grap the tripID and then populate the datasource, which populates the repeater. Unfortunately, my repeater is just being populated with the last tripID specified.

  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="pkiTripID"
                    DataSourceID="SqlDataSource2" PageSize="20" AllowPaging="True" 
                    Width="100%" AllowSorting="True"
                    GridLines="None" onrowdatabound="GridView1_RowDataBound1">                 
                    <Columns>
                        <asp:BoundField DataField="TripType1" HeaderText="Type" SortExpression="TripType1" />
                        <asp:BoundField DataField="RegionName" HeaderText="Region" SortExpression="RegionName" />
                        <asp:TemplateField HeaderText="Country" HeaderStyle-ForeColor="#FF7900">
                            <ItemTemplate>
                                <asp:Repeater ID="RepeatCountry" runat="server"  
                                    DataSourceID="dsCountryByTripID" onitemdatabound="RepeatCountry_ItemDataBound">
                                    <ItemTemplate>
                                        <%# DataBinder.Eval(Container.DataItem, "CountryName") %>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </ItemTemplate>
                            <HeaderStyle ForeColor="#FF7900" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="OverallRating" HeaderText="Trip Rating" 
                            SortExpression="OverallRating" />
                        <asp:BoundField DataField="DepartureDate" HeaderText="Date" SortExpression="DepartureDate"
                            DataFormatString="{0:MMM-dd-yyyy}" HtmlEncode="false" />
                    </Columns>
                </asp:GridView> 

 <asp:SqlDataSource ID="dsCountryByTripID" runat="server" 
        ConnectionString="<%$ ConnectionStrings:myDB %>" 
        SelectCommand="spSelectCountriesByTripID" SelectCommandType="StoredProcedure">
        <SelectParameters>
        <asp:Parameter Type="Int32" Name="tripID"  DefaultValue="96" />
        </SelectParameters>
    </asp:SqlDataSource>

And my code behind

  protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
    {
        Repeater rp = (Repeater)e.Row.FindControl("RepeatCountry");

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            dsCountryByTripID.SelectParameters.Clear();
            DataRowView drv = (DataRowView)e.Row.DataItem;
            string tripID = (drv["pkiTripId"]).ToString();
            dsCountryByTripID.SelectParameters.Clear();
            dsCountryByTripID.SelectParameters.Add("tripID", DbType.Int32, tripID);
            ////gv2.DataBind();
            //e.Row.DataBind();

        }
    }
    protected void RepeatCountry_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        e.Item.DataBind();
    }
  • 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-05-16T06:18:54+00:00Added an answer on May 16, 2026 at 6:18 am

    I decided not to use DataSource and use my own, I gave me more flexibility to bind the repeater(no need for gridview) within the gridview, before moving to the next row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview that displays items details, I added two template fields one
Good afternoon all. I have a page that displays data in a gridview based
In my Webforms 3.5 application, I have a GridView of users that displays the
I have a gridview that is within an updatepanel for a modal popup I
I currently have a gridview that has an asp:ButtonField as one of the columns.
I have a Gridview that displays paged results from a search query. The problem
I am creating a GridView/DetailsView page. I have a grid that displays a bunch
I have a gridview that displays the contents of a database table, using an
I have a gridview which displays rows and columns all linked to an sql
I have a ASP.NET/VB that had a GridView to display a list of users

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.