I wasn't sure what parts of the code you'd want. Here's the first (parent) gridview -
CODE
<asp:GridView ID="grvservers" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="serverid" DataSourceID="sdsservers"
Font-Names="Arial" ForeColor="#333333" GridLines="None" Width="100%" Font-Size="Small" PageSize="15">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ShowSelectButton="True" CausesValidation="False" />
<asp:BoundField DataField="serverid" HeaderText="serverid" InsertVisible="False"
ReadOnly="True" SortExpression="serverid" Visible="False" />
<asp:BoundField DataField="servername" HeaderText="Name" SortExpression="servername">
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="servertype" HeaderText="Type" SortExpression="servertype">
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
The second one -
CODE
<asp:GridView ID="grvnotes" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="noteid"
DataSourceID="sdsservernotes" Font-Names="Arial" Font-Size="Small" ForeColor="#333333"
GridLines="Horizontal" HorizontalAlign="Left" Width="100%" EmptyDataText="No notes for this server">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField ShowHeader="False">
<ControlStyle ForeColor="Black" />
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
OnClientClick="return confirm ( 'Are you sure you want to delete this note?' )" Text="Delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="noteid" HeaderText="noteid" InsertVisible="False" ReadOnly="True"
SortExpression="noteid" Visible="False" />
<asp:TemplateField HeaderText="Note" SortExpression="notetext">
<EditItemTemplate>
<asp:RequiredFieldValidator ID="rfvservernote" runat="server" BackColor="White" ControlToValidate="TextBox1"
ErrorMessage="RequiredFieldValidator">You must enter something into the Note field</asp:RequiredFieldValidator>
<asp:TextBox ID="TextBox1" runat="server" CausesValidation="True" Text='<%# Bind("notetext") %>'
Width="100%"></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("notetext") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="dateadded" HeaderText="Added" SortExpression="dateadded" ReadOnly="True" >
<ItemStyle Width="15%" />
</asp:BoundField>
<asp:BoundField DataField="addedby" HeaderText="Added By" SortExpression="addedby" ReadOnly="True" >
<ItemStyle Width="15%" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
</asp:GridView>
The datasource for the first one -
CODE
<asp:SqlDataSource ID="sdsservers" runat="server" ConnectionString="<%$ ConnectionStrings:serverlogConnStr %>"
SelectCommand="SELECT serverid, servername, vmhost, compendiaversion, servertype FROM Servers
where deleted is null and externalflag = @externalflag"
UpdateCommand="UPDATE Servers SET servername =@servername, compendiaversion =@compendiaversion, servertype =@servertype WHERE serverid = @serverid
">
<UpdateParameters>
<asp:Parameter Name="servername" />
<asp:Parameter Name="compendiaversion" />
<asp:Parameter Name="servertype" />
<asp:Parameter Name="serverid" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="ddlextflag" DefaultValue="N" Name="externalflag"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
The datasource for the second -
CODE
<asp:SqlDataSource ID="sdsservernotes" runat="server" ConnectionString="<%$ ConnectionStrings:serverlogConnStr %>"
SelectCommand="SELECT [noteid], [notetext], [dateadded], [addedby] FROM [Server_Notes] WHERE ([serverid] = @serverid)" DeleteCommand="DELETE FROM Server_Notes
WHERE noteid = @noteid" UpdateCommand="UPDATE Server_Notes SET notetext =@notetext
WHERE noteid = @noteid">
<SelectParameters>
<asp:ControlParameter ControlID="dvservers" Name="serverid" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="noteid" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="notetext" />
<asp:Parameter Name="noteid" />
</UpdateParameters>
</asp:SqlDataSource>
I do databind() in the selectedindexchanged and the rowcommand events of the first one.