Step 1

Copy and paste inline code in body tag

InLine Code

<asp:DataList ID="outerDataList" runat="server"

OnItemDataBound="outerRep_ItemDataBound"

Width="147px" RepeatColumns="4" BackColor="White"

BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4"

GridLines="Both" Height="79px">

<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />

<ItemTemplate>

<br />

<table class="style39">

<tr>

<td class="style45" colspan="2" align="left" valign="top">Organ System</td>

</tr>

<tr>

<td valign="top" class="style45" align="left">

<asp:Label ID="lblCategoryName" runat="server" Font-Bold="True"

Font-Names="Times New Roman" Font-Size="Medium"

Text='<%# Eval("test_system") %>' ForeColor="Black" />

<br />

</td>

<td>

</td>

</tr>

<tr>

<td class="style45" align="left">

&
|nbsp;
</td>

<td>

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"

BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"

CellPadding="4" ForeColor="Black" GridLines="Horizontal" Width="176px">

<Columns>

<asp:BoundField DataField="medical_test" HeaderText="Test Name">

<ItemStyle Width="20%" />

</asp:BoundField>

<asp:BoundField DataField="med_test_value" HeaderText="Test Value">

<ItemStyle Width="20%" />

</asp:BoundField>

</Columns>

<FooterStyle BackColor="#CCCC99" ForeColor="Black" />

<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />

<PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />

<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />

</asp:GridView>

</td>

</tr>

</table>

<br />

</ItemTemplate>

<ItemStyle BackColor="White" ForeColor="#003399" />

<SelectedItemStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />

<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />

</asp:DataList>

Step 2

Put this code on Page_Load event to bind DataList

Code Behind

DataBaseHnadler _DataBaseHnadler = new DataBaseHnadler();

DataTable _DataTable1 = _DataBaseHnadler.getData("select Distinct

(Test_System) from test_master");

foreach (DataRow r in _DataTable1.Rows)

{

try

{

outerDataList.DataSource = _DataTable1;

outerDataList.DataBind();

}

catch (Exception ex) { lblerror.Text = ex.Message; }

}

Step 3

Bind Inner Gridview.

Go to DataList Event and create ItemDataBound event of Data List.

And Bind Gridview Inside DataList

protected void outerRep_ItemDataBound(object sender, DataListItemEventArgs e)

{

DataRowView drv = e.Item.DataItem as DataRowView;

GridView innerDataList = e.Item.FindControl("GridView2") as GridView;

Label lbl = (Label)e.Item.FindControl("lblCategoryName");

DataTable _DataTable2 = new DataTable();

_DataTable2 = _DataBaseHnadler.getData("select * from fpay_med_trans");

foreach (DataRow rw in _DataTable2.Rows)

{

innerDataList.DataSource = _DataTable2;

innerDataList.DataBind();

}

}