你能帮我解决这个问题吗?当我单击 ID 1,2.... 时,从查询字符串中获取 ID 并在另一个表中的 id_proba 上显示查询字符串中的 id 相等的那些名称。这没关系,给我看看。现在我喜欢在 GridView1 中单击 ID 1,2.. 以仅刷新 gridview 2 而不是所有页面。需要 gridview 放入 Ajax 更新面板。我将 gridview2 放在更新面板中,但不知道在代码中写什么?
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource1" CellPadding="4"
ForeColor="#333333" GridLines="None"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
<asp:HyperLinkField
DataTextField="id"
DataTextFormatString=" {0}"
DataNavigateUrlFields="id" HeaderText="id"
DataNavigateUrlFormatString="WebForm1.aspx?ID={0}" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ProbaConnectionString %>"
DeleteCommand="DELETE FROM [Proba1] WHERE [id] = @id"
InsertCommand="INSERT INTO [Proba1] ([name]) VALUES (@name)"
SelectCommand="SELECT [name], [id] FROM [Proba1]"
UpdateCommand="UPDATE [Proba1] SET [name] = @name WHERE [id] = @id">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="name" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource2">
<Columns>
<asp:BoundField DataField="id_proba" HeaderText="id_proba"
SortExpression="id_proba" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
</Columns>
</asp:GridView>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ProbaConnectionString %>"
SelectCommand="SELECT [id_proba], [name] FROM [proba3] WHERE ([id_proba] = @id_proba)">
<SelectParameters>
<asp:QueryStringParameter Name="id_proba" QueryStringField="ID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>