Click here to Skip to main content
15,891,136 members
Articles / Web Development / HTML

Gridview Inside a GridView in ASP.NET 2.0

Rate me:
Please Sign up or sign in to vote.
4.45/5 (57 votes)
30 May 20066 min read 629.5K   10.6K   200  
An article on how to use a GridView control in ASP.NET 2.0, having multiple controls in templates inside it.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ChildTable" targetNamespace="http://tempuri.org/ChildTable.xsd" xmlns:mstns="http://tempuri.org/ChildTable.xsd" xmlns="http://tempuri.org/ChildTable.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:annotation>
    <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
      <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
        <Connections>
          <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="TestConnectionString" ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly" Name="TestConnectionString (Web.config)" ParameterPrefix="@" PropertyReference="AppConfig.System.Configuration.ConfigurationManager.0.ConnectionStrings.TestConnectionString.ConnectionString" Provider="System.Data.SqlClient">
          </Connection>
        </Connections>
        <Tables>
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="ChildTableTableAdapter" GeneratorDataComponentClassName="ChildTableTableAdapter" Name="ChildTable" UserDataComponentName="ChildTableTableAdapter">
            <MainSource>
              <DbSource ConnectionRef="TestConnectionString (Web.config)" DbObjectName="dbo.ChildTable" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="True" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="False" UserGetMethodName="GetData" UserSourceName="Fill">
                <DeleteCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>DELETE FROM [ChildTable] WHERE (([ChildTableID] = @Original_ChildTableID))</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_ChildTableID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="ChildTableID" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </DeleteCommand>
                <InsertCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>INSERT INTO [ChildTable] ([MasterTableID], [ChildName], [ChildSatus]) VALUES (@MasterTableID, @ChildName, @ChildSatus)</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@MasterTableID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="MasterTableID" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@ChildName" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="ChildName" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Boolean" Direction="Input" ParameterName="@ChildSatus" Precision="0" ProviderType="Bit" Scale="0" Size="0" SourceColumn="ChildSatus" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </InsertCommand>
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="True">
                    <CommandText>SELECT     ChildTableID, MasterTableID, ChildName, ChildSatus
FROM         ChildTable
WHERE     (MasterTableID = @MasterTableID)</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="MasterTableID" ColumnName="MasterTableID" DataSourceName="[C:\DOCUMENTS AND SETTINGS\NIKHIL.CONTRACTOR\MY DOCUMENTS\VISUAL STUDIO 2005\WEBSITES\GRIDVIEWINSIDEGRIDVIEW\APP_DATA\TEST.MDF].dbo.ChildTable" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@MasterTableID" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="MasterTableID" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </SelectCommand>
                <UpdateCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>UPDATE [ChildTable] SET [MasterTableID] = @MasterTableID, [ChildName] = @ChildName, [ChildSatus] = @ChildSatus WHERE (([ChildTableID] = @Original_ChildTableID))</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@MasterTableID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="MasterTableID" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@ChildName" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="ChildName" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Boolean" Direction="Input" ParameterName="@ChildSatus" Precision="0" ProviderType="Bit" Scale="0" Size="0" SourceColumn="ChildSatus" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_ChildTableID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="ChildTableID" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </UpdateCommand>
              </DbSource>
            </MainSource>
            <Mappings>
              <Mapping SourceColumn="ChildTableID" DataSetColumn="ChildTableID" />
              <Mapping SourceColumn="MasterTableID" DataSetColumn="MasterTableID" />
              <Mapping SourceColumn="ChildName" DataSetColumn="ChildName" />
              <Mapping SourceColumn="ChildSatus" DataSetColumn="ChildSatus" />
            </Mappings>
            <Sources>
            </Sources>
          </TableAdapter>
        </Tables>
        <Sources>
        </Sources>
      </DataSource>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="ChildTable" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="ChildTable" msprop:Generator_DataSetName="ChildTable">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="ChildTable" msprop:Generator_UserTableName="ChildTable" msprop:Generator_RowDeletedName="ChildTableRowDeleted" msprop:Generator_RowChangedName="ChildTableRowChanged" msprop:Generator_RowClassName="ChildTableRow" msprop:Generator_RowChangingName="ChildTableRowChanging" msprop:Generator_RowEvArgName="ChildTableRowChangeEvent" msprop:Generator_RowEvHandlerName="ChildTableRowChangeEventHandler" msprop:Generator_TableClassName="ChildTableDataTable" msprop:Generator_TableVarName="tableChildTable" msprop:Generator_RowDeletingName="ChildTableRowDeleting" msprop:Generator_TablePropName="_ChildTable">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="ChildTableID" msdata:ReadOnly="true" msdata:AutoIncrement="true" msprop:Generator_UserColumnName="ChildTableID" msprop:Generator_ColumnVarNameInTable="columnChildTableID" msprop:Generator_ColumnPropNameInRow="ChildTableID" msprop:Generator_ColumnPropNameInTable="ChildTableIDColumn" type="xs:int" />
              <xs:element name="MasterTableID" msprop:Generator_UserColumnName="MasterTableID" msprop:Generator_ColumnVarNameInTable="columnMasterTableID" msprop:Generator_ColumnPropNameInRow="MasterTableID" msprop:Generator_ColumnPropNameInTable="MasterTableIDColumn" type="xs:int" />
              <xs:element name="ChildName" msprop:Generator_UserColumnName="ChildName" msprop:Generator_ColumnVarNameInTable="columnChildName" msprop:Generator_ColumnPropNameInRow="ChildName" msprop:Generator_ColumnPropNameInTable="ChildNameColumn" minOccurs="0">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="50" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="ChildSatus" msprop:Generator_UserColumnName="ChildSatus" msprop:Generator_ColumnVarNameInTable="columnChildSatus" msprop:Generator_ColumnPropNameInRow="ChildSatus" msprop:Generator_ColumnPropNameInTable="ChildSatusColumn" type="xs:boolean" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
    <xs:unique name="Constraint1" msdata:PrimaryKey="true">
      <xs:selector xpath=".//mstns:ChildTable" />
      <xs:field xpath="mstns:ChildTableID" />
    </xs:unique>
  </xs:element>
</xs:schema>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) Self Employed
India India
I am working as Software Profession in Sungard Offshore Services.Basically i have stared with Java,Java servlet and oracle then shifted to .Net.Since 3.5 years i am working in .Net.I am very much impressed with my one Project leader Mr.Deep Ambarkar.I have learnt so much things form him and i am very much thankful to him.

Comments and Discussions