我有3個gridviews選中gridview,用嵌套的gridview填充gridview。不工作。 helppp
1st gridview啓用選擇,如果它有任何數據將填充第二個gridview。
而第三個gridview嵌套在第二個gridview中。
但是,第三個gridview永遠不會顯示任何單個數據.. 我在想什麼?
我可以實現這一點,如果第二個gridview填充頁面加載。 這裏是代碼 IM在asp.net C#
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="SurveyID" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="SurveyID" HeaderText="SurveyID"
SortExpression="SurveyID" />
<asp:BoundField DataField="SurveyTitle" HeaderText="SurveyTitle"
SortExpression="SurveyTitle" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="SELECT [SurveyID], [SurveyTitle] FROM [Survey]">
</asp:SqlDataSource>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
DataKeyNames="QuestionID" DataSourceID="SqlDataSource2">
<Columns>
<asp:BoundField DataField="QuestionID" HeaderText="QuestionID"
InsertVisible="False" ReadOnly="True" SortExpression="QuestionID" />
<asp:BoundField DataField="QuestionTitle" HeaderText="QuestionTitle"
SortExpression="QuestionTitle" />
<asp:BoundField DataField="AnswerType" HeaderText="AnswerType"
SortExpression="AnswerType" />
<asp:TemplateField>
<ItemTemplate>
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" DataKeyNames="ResultID">
<Columns>
<asp:BoundField DataField="ResultID" HeaderText="ResultID"
SortExpression="ResultID" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="QuestionID" HeaderText="QuestionID"
SortExpression="QuestionID" />
<asp:BoundField DataField="AnswerValue" HeaderText="AnswerValue"
SortExpression="AnswerValue" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="SELECT * FROM [Results] WHERE ([QuestionID] = @QuestionID)">
<SelectParameters>
<asp:Parameter Name="QuestionID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="SELECT [QuestionID], [QuestionTitle], [AnswerType] FROM [Question] WHERE ([SurveyID] = @SurveyID)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="SurveyID"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
顯示你已經嘗試過。 http://stackoverflow.com/faq這是VB.NET或C#? – 2011-12-20 13:36:37
已更新。是.net c# – 2011-12-20 13:43:50