Вы можете добавить HiddenField
в ItemTemplate GridView1 и связать его с QuestionID
.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
...
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="HiddenField1" runat="server"
Value='<%# Eval("QuestionID") %>' />
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
BorderStyle="Solid" DataSourceID="SqlDataSource2">
<Columns>
<asp:BoundField DataField="AnswerValue" HeaderText="AnswerValue"
SortExpression="AnswerValue" />
</Columns>
</asp:GridView>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
и использовать ControlParameter для сравнения QuestionID с SqlDataSource2.
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="SELECT AnswerValue FROM Results WHERE (QuestionID = @QuestionID)">
<SelectParameters>
<asp:ControlParameter ControlID="HiddenField1" Name="QuestionID"
PropertyName="Value" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>