.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

nested gridview design

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :ASP.Net

 I have a comment system I use the nested gridview to display the comments and the related subcomments
now i have problem with the html design
there is a space between subcomments and comments
can you make the design better

<asp:GridView ID="userComments" runat="server" AutoGenerateColumns="False" EnableViewState="False"
            AllowPaging="True" Width="100%" CellPadding="4" EnableModelValidation="True"
            GridLines="None" ForeColor="#333333" >
                        <tr style="background-color: #E8E8E8;"&

View Complete Post

More Related Resource Links

Editable multiple nested gridview


Greetings everyone,

I've got this page where I display a 3 level nested gridview. First gridview displays data, 2nd one displays data based on the 1st one's row and 3rd one displays data based on the 2nd gridview. All of this works perfectly, including the edit mode for the 3rd gridview. 

The issue comes when I make each gridview collapsible, again, it works fine but when I click on "Edit" on the 3rd gridview all the grids collapse, I can then re-open them and the "edit mode" is still present and I can still save my updated data. But that collapsing thing is quite annoying.

I based a lot of my code from this page: http://www.codeproject.com/KB/webforms/EditNestedGridView.aspx

And I understand how I can fix my issue on a 2 level nested gridview, by simply adding the C# code:

protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
            GridView gvTemp = (GridView)sender;
            gvUniqueID = gvTemp.UniqueID;
            gvEditIndex = e.NewEditIndex;

This makes allows me to save the index and prevent it from collapsing when I'm editing. Unfortunately, because I'm actually editing the 3rd gridview, if I code:

Nested gridview to show category and forum

hi,I would like to do like this forum http://www.vbforums.com/there is category and under its there are all forum of this category to do that , I create 2 tables in DB cat for category have 2 rows ( id,title) and table forum have 3 rows ( id,title,Cat_ID) I can do it with Php but in asp.net I can'tI read in some article to create  nested gridviewI try but I didn't find solution and thanks

how to use nested gridview's rowupdating event

Hi all,            I have a GridView within a GridView. I want o access child gridview's rowupdating event. i want to update row.            this is my GridView's code as follows<asp:GridView ID="grdv1" runat="server" AutoGenerateColumns="false" EmptyDataText="No records found" OnRowDataBound="grdv1_RowDataBound" CellPadding="0" Width="500px" CellSpacing="0" BorderWidth="0"> <Columns> <asp:TemplateField> <ItemTemplate> <table width="100%"> <tr> <td align="center"> <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' CssClass="nbdcontent"></asp:Label> </td> </tr> <tr> <td style="height: 150px"> <asp:GridView ID="grdv2" runat="server" AutoGenerateColumns="False&

How to find specific nested object type in Gridview

Dears, I have a gridview with a nested placeholder in each rows. I nested some checkboxes in each placeholders in each rows dynamically, so their ServerIDs are not the same (I dont want to use nested gridview). at the end in a button event I want to count checked checkboxes in gridview while I can not use findcontrol() method in each rows to find checkboxes due to their different ServerIDs. How can I do this?

Nested Gridview and databinding

protected void grdClientPayments_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { GridView gv = (GridView)e.Row.FindControl("grdPayments"); SqlDataSource dbSrc = new SqlDataSource(); dbSrc.ConnectionString = NFMData.DB.GetDBConn(); dbSrc.SelectCommand = "SELECT APR.PaymentID, APR.AdID, PaymentAmount, PaymentDate, CheckNo, APR.Comments " + "FROM AdPaymentReceived APR " + "LEFT OUTER JOIN ISRPayment_Payments IPP ON IPP.PaymentID = APR.PaymentID " + "WHERE ISNULL(IPP.Amount,0) <= 0 AND APR.AdID = " + ((DataRowView)e.Row.DataItem)["AdID"].ToString(); gv.DataSource = dbSrc; gv.DataBind(); foreach (GridViewRow gvRow in gv.Rows) { if (gvRow.RowType == DataControlRowType.DataRow) { decimal PaymentAmount = (decimal)((DataRowView)gvRow.DataItem)["PaymentAmount"]; } } }   So basically what I'm trying to do is do some calculation on the rows in the sub-grid based on some values in the main grid.

Help:JAVASCRIPT (checkAll) & (Hide/Unhide GridView1) in a Datalist with a nested Gridview


Hey guys,

 I'm at my wits end on this one looked/Searched/Played/Experimented and I need your help if you can.

This page is going to be primarily used on a mobile device using Win Mobile 5


Need to Accomplish:

  1. Prevent Postback(serverside) of Page using JavaScript (Postback's slow down the page on mobile device)


JavaScript Requests:

  1. Hide and UnHide the Nested Gridview1 by Clicking on a imagebutton1 in DataList1icon_minized_collapse.pngicon_expand_collapse.png
  2. CheckBox in DataList1 Checks All and UNChecks All, CheckBox in just the related Gridview1


Controls :

  1. Gridview1 nested inside DataList1


Note: Datalist1 and Gridview1 have datasource's in production. The Codebehind page is just appling test data to help me figure this out.


Thank you all in advance for helping me with this.

Example data below:<

Nested gridView Position fixes when scrolling



I have a gridview with a nested gridview, the nested gridview exoands on the click of a button driven by some java


the parent gridview is in a panel with virtical scroll bar enabled.


In the development area I can expand a nested gridview and scroll down and it will travel with the parent in the correct position.

When published the nested gridview has a fixed position and wontn scroll with the parent.


Any ideas?


Thanks in advance

How to fetch data from nested gridview


Hi, Please guide me how to fetch data from Nested gridview checkbox on Click button event which is present outside the gridview. I did try by creating an object of child gridview on button1_click but cannot fill the value from Gridview2 into my int i. Below mentioned is the Code i am using. The database I am using is Oracle.

 ==== Code =====

 protected void Button1_Click(object sender, EventArgs e)


OracleConnection con = new OracleConnection();

        con.ConnectionString = ConfigurationSettings.AppSettings["oracle"];

        //int RowIndex = Convert.ToInt32(e.CommandArgument);


        //GridView subGrid = (GridView)GridView1.Rows[RowIndex].FindControl("GridView2");


        //GridView subGrid = (GridView)GridView1.FindControl("GridView2");

        int i = 0;

        GridView subGrid =((GridView)GridView1.Rows[i].FindControl("GridView2"));


Nested Gridview Edit Event


I have a Parent gridview with a nested gridview. Edit on the parent works fine. On the nested child gridview, when I click the edit button, the line goes into edit mode, but the parent row collapses.  To correct I added javascript to call the javascript function that is used to expand and collapse the rows.  It is located in the RowDataBound event of the parent gridview.  Based on the code samples I have, the way the process should work when the edit button is clicked is the RowCommand and then the RowEditing events for the child gridview are supposed to fire, followed by the RowDataBound for the parent.  The child events are firing after the parent though.  This wouldn't be a problem except that I am retrieving the parent line that holds the child record being edited so that value can be fed to the javascript function to expand the row. How can I fix this or work around it?

inner gridview in nested gridview not firing onRowCommand


 i have the following nested gridview

i could get the inner gridview onRowDataBound working by setting that directly in the gridview

but i cannot get the linkbutton's onrowCommad inside the inner gridview working!!!

it does not fire the event even i have set it directly in the gridview

here is the code in my app_code page

 Protected Sub deleteSubComment_RowCommand(ByVal sender As Object, ByVal E As GridViewCommandEventArgs)
            If E.CommandName = "deleteSubComment" Then
                Dim ID As Integer = Convert.ToInt32(E.CommandArgument)
            End If
        End Sub


<asp:GridView ID="userComments" runat="server" AutoGenerateColumns="False" EnableViewState="False"

Nested GridView Control returns "Object variable or With block variable not set" when outer GridView


Nested GridView Control returns "Object variable or With block variable not set" when outer GridView returns rows.

The Nested GridView Control works as long as the outer GridView returns rows, the following code works:


Protected Sub GridViewReport_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridViewReport.RowCreated

          If e.Row.RowType = DataControlRowType.DataRow Then

                 Dim myStatus_ID As SqlDataSource = CType(e.Row.FindControl("sqlDeviceStatusAssign"), SqlDataSource)
                 If Not e.Row.DataItem("Status_ID") Is Nothing Then
                                  myStatus_ID.SelectParameters(0).DefaultValue = e.Row.DataItem("Status_ID")
                 End If

       End If

Problem :- using AJAX and GridView in a nested master Page


HI ,

Have been scratching my head regarding

"Control with ID 'GRID1' being registered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement either INamingContainer, IPostBackDataHandler, or IPostBackEventHandler."

-------not using any update panels in masterpages.

-------grid.databind on page load of content page.

any help is really appreciated.

Thank you

Nested Gridview Show/Hide ?



I have a nested content in a grid.

I have to show that content on click of show button and similar to hide the same button i have to click.

It should be in client side.

I have done like this, when i click on show/hide in the bottom of <p> tag all the content of the grid it's showing and similar for hide also happening.

If any one have good code apart from this, please i needed ur help.

<script type="text/javascript" src="jquery.js"></script>

    <script type="text/javascript">

    <style type="text/css">
border:solid 1px #c3c3c3;
    <form id="form1" runat="server">
        <asp:GridView ID="g1" runat="

Its a task which had never before... how to get column and design in gridview Dynamic based on value



I need to generate gridview based on table value... let us consider i have in my aspx page one dropdownlist in which i have binded somevale

for example: dropdownlist contain:- Item1

based on Item1 i have three table first table conists A,B,C,D value.

Second Table consist 1,2,3,4,5

Third Table consist (0.5,0.6,0.7) for 1, (0.7,1.0) for 2, (0.6) for 3, (0.8) for 4, and another(0.8) for 5

based on this three table i need to show girdview like this which is below

If its Item2 dropdownlist then row  and column of girdview will be any number based on first,second,third table value for Item2

like this if Item3 dropdownlist then row  and column of girdview will be any number based on first,second,third table value for Item3.

help me to achieve dynamic rows and column based on database value... 

Its a very help if you guys will give me code in asp.net C#....

Bind gridview column to nested object



not really sure how to phrase this question.

If I have a list of contacts List<Contact> and a Contact object has an Office object property, I want to display a grid with columns

Contact Id, First Name, Last Name, Office Name

Where the sources of the above columns are respectively:

Contact.ContactId, Contact.FirstName, Contact.LastName, Contact.Office.OfficeName

I'm fine with binding the first 3, but was wondering whether I can bind the OfficeName using either Bind or Eval or whether I need to hook into the events and set the value there.






Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.

Abstract Factory Design in C# , Vb.NET

Provide an interface for creating families of related or dependent objects without specifying their concrete classes
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend