Click here to Skip to main content
15,887,331 members
Articles / Web Development / ASP.NET
Article

Editable Nested DataGrid

Rate me:
Please Sign up or sign in to vote.
4.81/5 (52 votes)
11 Mar 2007CPOL5 min read 410.3K   4.9K   191   85
How to Create a Nested DataGrid in ASP.NET Using C#
Screenshot - EditNestedGridView.JPG

Introduction

This article explains how to make an ASP.NET Editable Nested GridView. Here I am going to explain how to provide all the features of Edit/Add/Delete/Update/Page/Sort of a GridView, and not only one GridView, but I am going to explain how to extend these features to even nested grids (GridView inside GridView). I have provided the fully functional source code, which is self-explanatory.

Background

My previous article explains about the features of Nested Editable DataGrid. This article provides all those features in GridView (Visual Studio 2005, .NET 2.0). With the combination of GridView and DataSource controls, it's very easy to create an Editable GridView.

Using the Code

This is a web application with a virtual directory named EditNestedGridView. You may create the same virtual directory to run this application with Visual Studio .NET 2005 or create any other virtual directory and map the path to this directory to access it from the browser. As I have used Access 2003 as my database, you need to have Microsoft Access installed on your machine. I have used NorthWind database with some modifications. I have included this also in the code bundle under the App_Data folder. I have used C# for codebehind files. In Visual Studio 2005, File --> Open --> Web Site and navigate to the folder EditNestedGridView.

Step-by-Step Procedure

The code attached is self-explanatory, but will try to explain as much as possible.

1. Since here I am going to use the DataSource control, let's first create a Access DataSource control as mentioned below.

ASP.NET
<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
    DataFile="App_Data/Northwind.mdb" 
    SelectCommand="SELECT [Customers].[CustomerID], 
    [Customers].[CompanyName],[Customers].[ContactName],
    [Customers].[ContactTitle],[Customers].[Address] FROM [Customers] 
    ORDER BY [Customers].[CustomerID]"></asp:AccessDataSource>

The main advantage of the DataSource control is that it simplifies the amount of custom code that needs to be written to retrieve and bind data, and even to sort, page through or edit data.

2. Now let's create a simple GridView control and attach the previously created DataSource control as below.

ASP.NET
<asp:GridView ID="GridView1" AllowPaging="True" BackColor="#f1f1f1" 
            AutoGenerateColumns=false DataSourceID="AccessDataSource1" 
            DataKeyNames="CustomerID"
            style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 32px" 
            ShowFooter=true Font-Size=Small
            Font-Names="Verdana" runat="server" GridLines=None BorderStyle=Outset>

GridView is very similar to DataGrid and it has all those column features of DataGrid like TemplateColumn, BoundColumn to populate data as columns. EditItemTemplate and FooterTemplate can be used for editing and adding purpose. Following code shows the columns of parent Grid.

ASP.NET
<asp:TemplateField HeaderText="Customer ID" SortExpression="CustomerID">
    <ItemTemplate>
        <asp:Label ID="lblCustomerID" Text='<%# Eval("CustomerID") %>' 
            runat="server"></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:Label ID="lblCustomerID" Text='<%# Eval("CustomerID") %>' 
            runat="server"></asp:Label>
    </EditItemTemplate>
    <FooterTemplate>
        <asp:TextBox ID="txtCustomerID" Text='' runat="server"></asp:TextBox>
    </FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Company Name" SortExpression="CompanyName">
    <ItemTemplate><%# Eval("CompanyName") %></ItemTemplate>
    <EditItemTemplate>
        <asp:TextBox ID="txtCompanyName" Text='<%# Eval("CompanyName") %>' 
            runat="server"></asp:TextBox>
    </EditItemTemplate>
    <FooterTemplate>
        <asp:TextBox ID="txtCompanyName" Text='' runat="server"></asp:TextBox>
    </FooterTemplate>
</asp:TemplateField>
..........................
..........................

<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
    <ItemTemplate>
        <asp:LinkButton ID="linkDeleteCust" CommandName="Delete" 
            runat="server">Delete</asp:LinkButton>
    </ItemTemplate>
    <FooterTemplate>
        <asp:LinkButton ID="linkAddCust" CommandName="AddCustomer" 
            runat="server">Add</asp:LinkButton>
    </FooterTemplate>
</asp:TemplateField>

Now that we have all the columns in place, we need the event handlers to take care of Add/Edit/Delete actions. Handling these events is very straightforward compared to DataGrid. The DataSource control takes care of the Paging and Sorting actions. Here is the final parent GridView control with all these events.

ASP.NET
<asp:GridView ID="GridView1" AllowPaging="True" BackColor="#f1f1f1" 
            AutoGenerateColumns=false DataSourceID="AccessDataSource1" 
            DataKeyNames="CustomerID"
            style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 32px" 
            ShowFooter=true Font-Size=Small
            Font-Names="Verdana" runat="server" GridLines=None 
            OnRowDataBound="GridView1_RowDataBound" 
            OnRowCommand = "GridView1_RowCommand" 
            OnRowUpdating = "GridView1_RowUpdating" BorderStyle=Outset
            OnRowDeleting = "GridView1_RowDeleting" 
            OnRowDeleted = "GridView1_RowDeleted"
            OnRowUpdated = "GridView1_RowUpdated" AllowSorting=true>

With all the above options, GridView looks like below.

Screenshot - EditNestedGridView1.jpg

3. Until now, we have created parent a GridView. Now we are going to extend these features in a child GridView as well.

Before adding another GridView, we must understand how GridView emits its content as HTML tags. For an Internet Explorer browser, GridView is like a regular Table with TR and TD tags. So, if we can manipulate the parent GridView to forcibly close a row and emit Child GridView as another ROW, we are done with it.

What is displayed is some HTML table cell and row tags that effectively intercept the current output that will be generated by the GridView with our own special implementation. Namely, we are telling the table (when it's drawn) to close the current cell, the current row and now add a new row with one blank column (for spacing) and another column (spanning all columns) that we'll use to display a second GridView. Here is the piece of code which explains this:

ASP.NET
<asp:TemplateField>
    <ItemTemplate>
        <tr>
        <td colspan="100%">
        <div id="div<%# Eval("CustomerID") %>" 
            style="display:none;position:relative;left:15px;OVERFLOW: auto;WIDTH:97%" >

Here I have created a division id="div Eval("CustomerID") with an ID of Customer (parent row) which holds Child GridView so that we can dynamically hide and expand it by using DIV ID. Also, we need a column in the main GridView which holds the image to expand and collapse the child GridView as below.

ASP.NET
<asp:TemplateField>
    <ItemTemplate>
        <a href="javascript:expandcollapse('div<%# Eval("CustomerID") %>', 'one');">

Here the JavaScript function expandcollapse will take care of expand and collapse action.

4. In order to bind the Child GridView, we can't use static DataSource control as we have used for parent GridView. We will have to dynamically prepare the query based on the Customer ID of the corresponding parent row and that we can do it in RowDataBound event of the parent Grid as below.

C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        GridViewRow row = e.Row;
        string strSort = string.Empty;

        // Make sure we aren't in header/footer rows
        if (row.DataItem == null)
        {
            return;
        }

        //Find Child GridView control
        GridView gv = new GridView();
        gv = (GridView)row.FindControl("GridView2");

        //Prepare the query for Child GridView by passing 
        //the Customer ID of the parent row
        gv.DataSource = 
            ChildDataSource(((DataRowView)e.Row.DataItem)["CustomerID"].ToString(), 
            strSort);
        gv.DataBind();
    }

Here the ChildDataSource function forms the query using the passed Customer ID and returns AccessDataSource.

5. Now we have data in Child Grid as well with dynamic expand and collapse. Let's add effects one by one as we did for parent grid. However, before going further, there is a little tricky part involved. In the case of the parent grid, there is only a unique ID (GridView1) and in the case of the child there will be several unique IDs that get generated at run time. If we can identify the one which we need, that will solve this problem.

Paging and Sorting were taken care of by DataSource control in the case of the parent grid. For the child grid, we have to take care of it manually using the corresponding events PageIndexChanging and Sorting. A sample code of paging event looks like below.

C#
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView gvTemp = (GridView)sender;
        gvUniqueID = gvTemp.UniqueID;
        gvNewPageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }

Here we have identified the run time Unique ID of the child grid which needs paging along with the new page number. We are going to use these variable values in the RowDataBound event of the parent grid as below.

C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        ........................
        //Find Child GridView control
        GridView gv = new GridView();
        gv = (GridView)row.FindControl("GridView2");
        //Check if any additional conditions (Paging, Sorting, Editing, etc) 
        //to be applied on child GridView
        if (gv.UniqueID == gvUniqueID)
        {
            gv.PageIndex = gvNewPageIndex;
            gv.EditIndex = gvEditIndex;
            //Check if Sorting used
            if (gvSortExpr != string.Empty)
            {
                GetSortDirection();
                strSort = " ORDER BY " + string.Format("{0} {1}", gvSortExpr, gvSortDir);
            }
            //Expand the Child grid
            ClientScript.RegisterStartupScript(GetType(), "Expand", 
                "<script language="javascript"></script>");
        }
        ..........................
    }

The remaining actions (Sorting/Edit/Update/Delete) can also be handled similarly to paging. Refer to the source code attached above.

Conclusion

GridView has more features compared to DataGrid, which will make it easier to code and also we can include HTML tags in between for more flexibility.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralPlaceHolder Tag Error Pin
Kim Chen15-Oct-07 11:21
Kim Chen15-Oct-07 11:21 
GeneralPlaceHoder Tag Error Pin
Kim Chen15-Oct-07 10:52
Kim Chen15-Oct-07 10:52 
GeneralReexpand parent after saved child Pin
mullemeck15-Oct-07 4:18
mullemeck15-Oct-07 4:18 
GeneralRe: Reexpand parent after saved child Pin
mullemeck15-Oct-07 4:47
mullemeck15-Oct-07 4:47 
GeneralC# code, please Pin
lamaguis_1201@yahoo.com.mx25-Aug-07 22:15
lamaguis_1201@yahoo.com.mx25-Aug-07 22:15 
GeneralSorting Problem in Nested Datagrid Pin
Rupali Rane22-Aug-07 0:07
Rupali Rane22-Aug-07 0:07 
GeneralChild Datagrid Sorting Error Pin
Rupali Rane22-Aug-07 0:05
Rupali Rane22-Aug-07 0:05 
GeneralProblem Regarding Nested Datagrid Pin
Rupali Rane22-Aug-07 0:02
Rupali Rane22-Aug-07 0:02 
Imports System.Data
Imports System.IO
Imports System.Data.SqlClient
Public Class WebForm3
Inherits System.Web.UI.Page
Shared numberDiv As Int32
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.StrConn = New System.Data.SqlClient.SqlConnection

End Sub
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents DataGrid2 As System.Web.UI.WebControls.DataGrid
Protected WithEvents lblOrderBy As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Strconn.ConnectionString = ConfigurationSettings.AppSettings.Item("ConnectMe")
End Sub

#End Region
#Region "Global Variables"
Dim dbas As New DataAccess
Dim sortdtset As New DataSet
'Dim CFn As New Class_Fn
Dim dgUniqueID As String
Dim dt As New Data.DataTable
Dim msql As String
'Public DdlMstrList As Data.DataTable
'Public DdlPCP As Data.DataTable
Dim StrConn As SqlConnection
Public ds As New DataSet

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
BindData()
BindData1()
End If

End Sub
Private Sub BindData1()
msql = ""
msql = "Select * from authors"

msql = msql + lblOrderBy.Text
dt = dbas.getDataTable(msql, StrConn.ConnectionString)
DataGrid2.DataSource = Nothing
DataGrid2.DataBind()
If Not dt Is Nothing Then
If dt.Rows.Count > 0 Then
DataGrid2.DataSource = dt
DataGrid2.DataBind()

End If
End If

End Sub

Private Sub BindData(Optional ByVal astrSort As String = "", Optional ByVal astrSort1 As String = "")

Dim lstrSQL As String
Dim ldtbParentTable As New DataTable
Dim ldtbChildTable As New DataTable

Dim lobjDataRelation As DataRelation
Dim lintPageSize As Int32
Dim llngTotalRec As Int32
'Dim conn
Dim dcAuthor
Dim daAuthor
Dim dcTitle
Dim daTitle

Try
'//Prepare the connection object

StrConn.Open()


'Query to get Customer Details - Parent Query


lstrSQL = "select au_id,au_lname,au_fname,city from authors"

Try

dcAuthor = New SqlCommand(lstrSQL, StrConn)
daAuthor = New SqlDataAdapter(dcAuthor)
daAuthor.Fill(ldtbParentTable)
ldtbParentTable.TableName = "ParentTable"

'Query to get Order Details - Child Query


lstrSQL = "select t.au_id as Childau_ID,t.title_id,t.au_ord,a.title,a.type,a.notes,a.pubdate from titleauthor t inner join titles a on t.title_id=a.title_id"

dcTitle = New SqlCommand(lstrSQL, StrConn)
daTitle = New SqlDataAdapter(dcTitle)
daTitle.Fill(ldtbChildTable)
ldtbChildTable.TableName = "ChildTable"
Session("dtchild") = ldtbChildTable
'Add both these tables to the dataset
ds.Tables.Add(ldtbParentTable)
ds.Tables.Add(ldtbChildTable)

'//Create relation and this relation name should be used on CreateChildView
Dim dr As New DataRelation("ParentTable_ChildTable", ldtbParentTable.Columns("au_id"), ldtbChildTable.Columns("Childau_ID"), False)
dr.Nested = True
ds.Relations.Add(dr)


Catch ex As Exception
ds = Nothing
End Try

'Set the datasource to parent datagrid

DataGrid1.DataSource = ds
DataGrid1.DataBind()
Session("dtsetI") = ds
'Dim dview As New DataView
'dview.Table.ParentRelations(0).RelationName = ds.Relations(0).RelationName
Catch exc As Exception
'LogMessage(exc)
Exit Sub
Finally
dcAuthor.Dispose()
daAuthor.Dispose()
dcTitle.Dispose()
daTitle.Dispose()
ds.Dispose()
StrConn.Close()
End Try
End Sub
Public Sub DataGrid3_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)

End Sub
Public Sub DataGrid3_ItemCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
BindData()
Dim dgTemp As New DataGrid
dgTemp = CType(source, DataGrid)
dgUniqueID = dgTemp.UniqueID
'BindData()

End Sub

Public Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
Dim strSQL As String

Select Case e.CommandName

Case "Expanded" '//Case for expanding the + sign on Parent grid to show the child grid

Dim img As ImageButton
Dim exp As PlaceHolder


'Before expanding, collapse previously opened child grid
Dim dgItem As DataGridItem

'For Each dgItem In DataGrid1.Items
' If dgItem.ItemIndex = Session("PrevItemIndex") And dgItem.ItemIndex <> e.Item.ItemIndex Then
img = e.Item.Cells(0).FindControl("ImageButton1")
If img.ImageUrl = "Images/Plus.GIF" Then
img.ImageUrl = "Images/Minus.GIF"
Else
img.ImageUrl = "Images/Plus.GIF"
End If

exp = e.Item.Cells(5).FindControl("Expanded")
exp.Visible = Not exp.Visible

' Exit For
' End If
'Next

'img = e.Item.Cells(0).FindControl("ImageButton1")
'If img.ImageUrl = "Images/Plus.gif" Then
' img.ImageUrl = "Images/Minus.gif"
'Else
' img.ImageUrl = "Images/Plus.gif"
'End If

'exp = e.Item.Cells(2).FindControl("Expanded")
'exp.Visible = Not exp.Visible
'Session("PrevItemIndex") = e.Item.ItemIndex 'Store the ItemIndex in session variable
'Session("au_ID") = e.Item.Cells(1).Text 'Store the auID
' DataGrid1.SelectedIndex = e.Item.ItemIndex
End Select
End Sub

Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid1.SortCommand

sortdtset = Session("dtsetI")
Try
Dim dview As New DataTable
dview = sortdtset.Tables(0)
Dim dview1 As New DataView
dview1.Table = dview
If gridSortOrder = "" Then
gridSortOrder = "ASC"
DataGrid1.ToolTip = "Ascending Sort"
ElseIf gridSortOrder = "ASC" Then
gridSortOrder = "DESC"
DataGrid1.ToolTip = "Decending Sort"
ElseIf gridSortOrder = "DESC" Then
gridSortOrder = "ASC"
DataGrid1.ToolTip = "Ascending Sort"
End If
dview1.Sort = e.SortExpression & " " & gridSortOrder
DataGrid1.DataSource = dview1
DataGrid1.DataBind()
'GroupColumn(dgriddoctor, 0)
'sortdtset.Dispose()
Catch ex As Exception
'PageError(ex)
End Try
End Sub

Public Sub DataGrid3_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs)
Dim sortdtset1 As New DataSet
Dim dt1 As New Data.DataTable
Dim ldtbParentTable As New DataTable
Dim ldtbChildTable As New DataTable
'BindData()

sortdtset1 = Session("dtsetI")
ldtbParentTable = sortdtset1.Tables(0)
ldtbChildTable = sortdtset1.Tables(1)

'Dim dr As New DataRelation("ParentTable_ChildTable1", ldtbParentTable.Columns("au_id"), ldtbChildTable.Columns("Childau_ID"), False)
'dr = New DataRelation( dr.RelationName)


'dr.Nested = True
'sortdtset1.Relations.Add(dr)

'Try
Dim dview1 As New DataView
dt1 = sortdtset1.Tables(1)
dview1.Table = dt1
'If gridSortOrder = "" Then
' gridSortOrder = "ASC"
' 'DataGrid2.ToolTip = "Ascending Sort"
'ElseIf gridSortOrder = "ASC" Then
' gridSortOrder = "DESC"
' 'DataGrid2.ToolTip = "Descending Sort"
'ElseIf gridSortOrder = "DESC" Then
' gridSortOrder = "ASC"
' 'DataGrid2.ToolTip = "Ascending Sort"
'End If

dview1.Sort = e.SortExpression & " " & gridSortOrder

'dview1.Table.ParentRelations(sortdtset.Relations(0))

Dim a As String
Dim dgTemp As New DataGrid
dgTemp = CType(source, DataGrid)
a = dgTemp.UniqueID
dgTemp.DataSource = dview1
a = dgTemp.UniqueID
dgTemp.DataBind()

a = dgTemp.UniqueID


'dgTemp.DataSource = Session("dtsetI")


'dgTemp.DataSource = dview1

'dgTemp.DataKeyField = "Childau_ID"
'dgTemp.DataKeyField = "ParentTable_ChildTable1"
'DataGrid1.FindControl("datagrid3").DataBind()

'dgTemp.DataBind()


'Catch ex As Exception

'End Try

End Sub
Public Property gridSortOrder() As String
Get
Dim oSortOrder As Object = ViewState("gridSortOrder")
If oSortOrder Is Nothing Then
Return "ASC"
End If
gridSortOrder = oSortOrder
End Get
Set(ByVal Value As String)
ViewState("gridSortOrder") = Value
End Set
End Property

Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
BindData()

End Sub

Private Sub DataGrid2_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid2.SortCommand

If ((numberDiv Mod 2) = 0) Then
lblOrderBy.Text = " ORDER BY " & e.SortExpression + " " + "ASC"
Else
lblOrderBy.Text = " ORDER BY " & e.SortExpression + " " + "DESC"
End If
numberDiv += 1
'lblOrderBy.Text = " ORDER BY " & e.SortExpression
BindData1()

End Sub

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound

End Sub
End Class
========================================================

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%>



<title>WebForm3




.DataGridFixedHeader { BACKGROUND: none transparent scroll repeat 0% 0%; POSITION: relative; ; TOP: expression(this.offsetParent.scrollTop) }




<asp:datagrid id="DataGrid1" runat="server" onitemcommand="DataGrid1_ItemCommand" height="128px"
="" borderstyle="Dotted" bordercolor="Silver" width="904px" datamember="ParentTable" allowsorting="True" backcolor="White" horizontalalign="Left" font-name="Verdana" font-size="9pt" autogeneratecolumns="False" itemstyle-verticalalign="Top" allowpaging="True" font-names="Verdana" cellpadding="2">
<footerstyle backcolor="Silver">
<itemstyle bordercolor="Transparent" verticalalign="Top">
<headerstyle font-size="10px" font-bold="True" horizontalalign="Center" backcolor="Silver">
<columns>
<asp:templatecolumn>
<itemtemplate>
<asp:imagebutton id="ImageButton1" runat="server" imageurl="Images/Plus.GIF" commandname="Expanded">


<asp:boundcolumn datafield="au_id" sortexpression="au_id" headertext="au_id" footertext="au_id">
<asp:boundcolumn datafield="au_lname" sortexpression="au_lname" headertext="au_lname" footertext="au_lname">
<asp:boundcolumn datafield="au_fname" sortexpression="au_fname" headertext="au_fname" footertext="au_fname">
<asp:boundcolumn datafield="city" sortexpression="city" headertext="city" footertext="city">
<asp:templatecolumn>
<headerstyle forecolor="White" borderstyle="Dotted" bordercolor="White" backcolor="White">
<itemstyle forecolor="White" borderstyle="Dotted" bordercolor="White" backcolor="White">
<itemtemplate>
<asp:placeholder id="Expanded" runat="server" visible="False">



<asp:datagrid id="Datagrid3" datasource="<%# Container.DataItem.CreateChildView("ParentTable_ChildTable") %>" datakeyfield="Childau_ID" runat="server" allowsorting="True" backcolor="Thistle" font-name="Verdana" font-size="8pt" autogeneratecolumns="false" itemstyle-verticalalign="Top" allowpaging="True" cellpadding="2" gridlines="Both" showfooter="false" enableviewstate="true" onsortcommand="DataGrid3_SortCommand" onitemcommand="Datagrid3_ItemCommand">
<alternatingitemstyle backcolor="#E0E0E0">
<headerstyle font-bold="True" horizontalalign="Center" forecolor="White" backcolor="DimGray">
<columns>
<asp:boundcolumn datafield="Childau_ID" sortexpression="Childau_ID" headertext="au_id" footertext="au_id">
<asp:boundcolumn datafield="title_id" sortexpression="title_id" headertext="title_id" footertext="title_id">
<asp:boundcolumn datafield="au_ord" sortexpression="au_ord" headertext="au_ord" footertext="au_ord">
<asp:boundcolumn datafield="title" sortexpression="title" headertext="title" footertext="title">
<asp:boundcolumn datafield="type" sortexpression="type" headertext="type" footertext="type">
<asp:boundcolumn datafield="notes" sortexpression="notes" headertext="notes" footertext="notes">
<asp:boundcolumn datafield="pubdate" sortexpression="pubdate" headertext="pubdate" footertext="pubdate">




<footerstyle forecolor="White" borderstyle="Dotted" bordercolor="White" backcolor="White">


<pagerstyle bordercolor="Transparent" backcolor="Transparent" mode="NumericPages">



<asp:datagrid id="DataGrid2" runat="server" borderstyle="None" bordercolor="#999999" width="872px"
="" allowsorting="True" backcolor="White" cellpadding="3" borderwidth="1px" gridlines="Vertical" autogeneratecolumns="False">
<footerstyle forecolor="Black" backcolor="#CCCCCC">
<selecteditemstyle font-bold="True" forecolor="White" backcolor="#008A8C">
<alternatingitemstyle backcolor="Gainsboro">
<itemstyle forecolor="Black" backcolor="#EEEEEE">
<headerstyle font-bold="True" forecolor="White" cssclass="DataGridFixedHeader" backcolor="#000084">
<columns>
<asp:boundcolumn datafield="au_id" sortexpression="au_id" headertext="au_id" footertext="au_id">
<asp:boundcolumn datafield="au_lname" sortexpression="au_lname" headertext="au_lname" footertext="au_lname">
<asp:boundcolumn datafield="au_fname" sortexpression="au_fname" headertext="au_fname" footertext="au_fname">
<asp:boundcolumn datafield="city" sortexpression="city" headertext="city" footertext="city">
<asp:templatecolumn sortexpression="state" headertext="State" footertext="State">
<itemtemplate>
<asp:dropdownlist id="DropDownList1" runat="server" cssclass="DataGridFixedHeader">



<pagerstyle horizontalalign="Center" forecolor="Black" backcolor="#999999" mode="NumericPages">



<asp:label id="lblOrderBy" style="Z-INDEX: 102; LEFT: 352px; POSITION: absolute; TOP: 264px"
="" runat="server" visible="False">




Rupali
GeneralGot an error Pin
Nagendra Kumar20-Aug-07 21:31
Nagendra Kumar20-Aug-07 21:31 
AnswerRe: Got an error Pin
Veera V Satya N Kanithi21-Aug-07 4:14
Veera V Satya N Kanithi21-Aug-07 4:14 
GeneralSimilar Solution using GridView Pin
Veera V Satya N Kanithi19-Aug-07 15:33
Veera V Satya N Kanithi19-Aug-07 15:33 
GeneralC# code Pin
T_Kan15-Aug-07 11:45
T_Kan15-Aug-07 11:45 
GeneralRe: C# code Pin
HariSir30-Nov-07 9:47
HariSir30-Nov-07 9:47 
QuestionDataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name OrderId. Pin
Naga Praveen Kumar Mulukutla9-Aug-07 21:14
Naga Praveen Kumar Mulukutla9-Aug-07 21:14 
AnswerRe: DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name OrderId. Pin
Veera V Satya N Kanithi13-Aug-07 7:46
Veera V Satya N Kanithi13-Aug-07 7:46 
QuestionOrderId is neither a DataColumn nor a DataRelation for table ChildTable. Pin
Naga Praveen Kumar Mulukutla9-Aug-07 21:11
Naga Praveen Kumar Mulukutla9-Aug-07 21:11 
Generalour examples of this grid in action Pin
marionjoe26-Jul-07 17:56
marionjoe26-Jul-07 17:56 
Questioncan grid record be editable ONLY by creator and admin? [modified] Pin
marionjoe26-Jul-07 17:37
marionjoe26-Jul-07 17:37 
Generalsuggestion Pin
zhaojicheng19-Jul-07 17:24
zhaojicheng19-Jul-07 17:24 
QuestionHow can assgin Datasource on GridView Pin
AnhTin28-Jun-07 23:28
AnhTin28-Jun-07 23:28 
AnswerRe: How can assgin Datasource on GridView Pin
Veera V Satya N Kanithi13-Aug-07 7:49
Veera V Satya N Kanithi13-Aug-07 7:49 
AnswerRe: How can assgin Datasource on GridView Pin
Veera V Satya N Kanithi19-Aug-07 15:28
Veera V Satya N Kanithi19-Aug-07 15:28 
QuestionBlows up in VS 2005 Pin
ayousuff31-May-07 11:42
ayousuff31-May-07 11:42 
GeneralAccessing the Controls in the Child Grid Pin
Lukeshields21-May-07 10:35
Lukeshields21-May-07 10:35 
AnswerRe: Accessing the Controls in the Child Grid Pin
Chris Palmeri10-Jun-07 5:23
Chris Palmeri10-Jun-07 5:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.