Link to home
Start Free TrialLog in
Avatar of dingir
dingirFlag for Sweden

asked on

Put a repeater inside a gridview

I'm about to put a repeater inside a gridview.

Below each row I want the list of all (to that row) related childrows.
Because I use ds_Selecting and get data to the gridview, i want to use this by asp.net.
Because of listing, sorting and so on..
Mostly of the samples i found are dousens of code file codes.

Some best pratice here?

So far I have this code to go from,

                <asp:GridView ID="gv" runat="server" Width="500px" AllowSorting="true" AllowPaging="false" PageSize="50"
                    AutoGenerateColumns="False"  DataSourceID="ds" EnableSortingAndPagingCallbacks="true" CellPadding="3" GridLines="None">
                    <Columns>
                        <asp:BoundField DataField="OrderItemId" ItemStyle-CssClass="hidden" />
                        <asp:BoundField DataField="Title" SortExpression="Title" ItemStyle-Width="230px" HeaderText="Title"  />
                        <asp:TemplateField>
                            <asp:GridView ID="gv2" DataSource="ds2" runat="server" AutoGenerateColumns="False">
                             <Columns>
                               <asp:BoundField DataField="Name" HeaderText="Name" />
                             </Columns>
                            </asp:GridView>
                        </asp:TemplateField>
                    </Columns>
                     <EmptyDataTemplate>
                     </EmptyDataTemplate>            
                </asp:GridView>

Codefile...

    protected void ds_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        DataContext db = new DataContext();
        e.Result = Class.GetItems(Current.Class.Id.ToString());
    }
Avatar of Muralidharanp
Muralidharanp

please explain ur question little bit clearer
Avatar of dingir

ASKER

Erhm i just want that way to populate the gridview to work..:)
Especially the inner gridview, the rest are of course working..

If I populate the inner gridview with an another datasource, how do I make it populated with each parent rowid as where statement?
ASKER CERTIFIED SOLUTION
Avatar of Muralidharanp
Muralidharanp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dingir

ASKER

Thank's for help..
I have tried this now and understand that I missunderstood some effects.
I want the subrows simply listed below the parent row. One line per match.

With this code, the subgridview (of course) apperars as an extra field.

Second,
The subrows are loaded with an own datasourceid, how do i put the correct parentrow as a parameter for that datasourceid? I need to put it code file because the data set are loaded from a class object..


    protected void BoundGv2(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
            ((System.Web.UI.WebControls.GridView)e.Row.FindControl("gv2")).DataBind();
    }

    protected void ds2_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        DataContext db = new DataContext();
        e.Result = Namespace.Core.GetRows(parentrowid);
    }

i am not able to get ur Question.please explain little bit cleare with an example
Avatar of dingir

ASKER

the result of the gridviews should be viewed as

Item 1    field1    field2
Choosen Option  1    price
Choosen Option  color red
Choosen Option  size   3

Item 2    field1    field2
Choosen Option  1    price  40$
Choosen Option  color red
Choosen Option  size   1


and so on,
u want to bind gridView2 based on value of GridView1 right? u wanna pass the value of particular column of gridview1 as a parameter to GridView2?
Avatar of dingir

ASKER

That's correct,
And in my sample, gridview 2 needs to repeat the data for each parent row,