BostCelt
asked on
Nested Grids in asp.net 2005
Experts, Please Please help
I have a nested grids. The parent grid is DataGrid (ParentGrid) and the child grid is Gridview (ChildGrid). How can I access to the childgrid to bind the data:
for example : ParentGrid.DataSource = dt; ParentGrid.DataBind();
but ChildGrid wasn't showing when I was looking for it to do the above work. I hope this is not a hard question.
Can anyone please help me?
I have a nested grids. The parent grid is DataGrid (ParentGrid) and the child grid is Gridview (ChildGrid). How can I access to the childgrid to bind the data:
for example : ParentGrid.DataSource = dt; ParentGrid.DataBind();
but ChildGrid wasn't showing when I was looking for it to do the above work. I hope this is not a hard question.
Can anyone please help me?
Are you saying that under each row of the parent gridview, you have a child gridview?
ASKER
Yes and my objective is I want to be able to see the entired record instead of 6 fields. Can we do that?
I assume the child gridview is defined in a TemplateField, right?
ASKER
Yes and Prairiedog, I have asked another question related to this topic. I have changed things around to try to make it work but I got stuck.
Here is my question: I want to display a record on the grid that has 5, 6 fields: first name, last name, DOB... and a plus (+) field and this + sign will allow the user to view the entired record (50 fields). I tried it by using gridview as main grid and DetailsView as inner grid so I can see all the fields in vertical. Is it possible? how can I make it work on the code behind? Can you help me with this?
PS: I was able to bind data to the main grid but can't make the detailsview work.
Any help will be appreciated.
Here is my question: I want to display a record on the grid that has 5, 6 fields: first name, last name, DOB... and a plus (+) field and this + sign will allow the user to view the entired record (50 fields). I tried it by using gridview as main grid and DetailsView as inner grid so I can see all the fields in vertical. Is it possible? how can I make it work on the code behind? Can you help me with this?
PS: I was able to bind data to the main grid but can't make the detailsview work.
Any help will be appreciated.
<table id="tblStaged" cellspacing="1" cellpadding="1" border="1" runat="server" style="width: 600px">
<tbody>
<tr>
<td class="userGrid" style="WIDTH: 900px; height: 600px;" valign="top">
<asp:GridView ID="GridStagedMain" runat="Server" Width="500px" BorderWidth="1px" BackColor="Gray"
AllowPaging="false" Font-Names="verdana" Font-Size="x-small" ForeColor="Black"
CellSpacing="0" CellPadding="2" CssClass="Shadow" DataKeyNames="VaultID" AutoGenerateColumns="false"
BorderStyle="None" BorderColor="Black">
<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>
<PagerStyle CssClass="form" HorizontalAlign="Right" />
<HeaderStyle CssClass="userGridHeader" ForeColor="#FF9900" Font-Size="X-Small"/>
<Columns>
<asp:BoundField ItemStyle-HorizontalAlign="center" DataField="VaultID" HeaderText="VaultID"/>
<asp:BoundField ItemStyle-HorizontalAlign="center" DataField="firstname" HeaderText="firstname" />
<asp:BoundField ItemStyle-HorizontalAlign="center" DataField="lastname" HeaderText="lastname" />
<asp:BoundField ItemStyle-HorizontalAlign="center" DataField="dob" HeaderText="DOB" />
<asp:BoundField ItemStyle-HorizontalAlign="center" DataField="gender" HeaderText="Gender" />
<asp:BoundField ItemStyle-HorizontalAlign="center" DataField="offensedate" HeaderText="offensedate" />
<asp:BoundField ItemStyle-HorizontalAlign="center" DataField="offensedescription" HeaderText="offensedescription" />
<asp:TemplateField HeaderText="Record Detail">
<ItemTemplate>
<div style="text-align:center;">
<asp:Button ID="btnStagedChild" Runat="server" Text="+" CommandName="+"></asp:Button></div>
<asp:Button ID="btnNoStagedChild" Runat="server" Text="-" CommandName="-" Onclick="NotDisplayStagedDetail" Visible="False"></asp:Button>
<asp:DetailsView ID="RecordDetail" runat="Server" DefaultMode="ReadOnly" HeaderText="Record Details">
<EmptyDataRowStyle Height="20px" />
<EditRowStyle Height="20px" />
<HeaderStyle BackColor="#CCCCCC" ForeColor="maroon" />
</asp:DetailsView>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</tbody>
</table>
private void LoadBindGrid()
{
DataSet ds = DBQABusinessLayer.DBQA.GetRecords();
DataView dv = ds.Tables[0].DefaultView;
//bind the data
GridStagedMain.DataSource = dv;
GridStagedMain.DataBind();
}
Hmmm, never done this before. Give me some time and let me see if I can find something.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
prairiedog:
I have come with different design where it first displays the grid and then the detailsview as the user click on the link button. I will try one of yours in the near future because I am close to my deadline for this one.
I still accepted it as a solution and gave you the points since you've stepped up and worked with me on it :-). I appreciated your help.
BC
I have come with different design where it first displays the grid and then the detailsview as the user click on the link button. I will try one of yours in the near future because I am close to my deadline for this one.
I still accepted it as a solution and gave you the points since you've stepped up and worked with me on it :-). I appreciated your help.
BC