我怎么能这样做,当我点击Gridview1中的ID时,我会像超链接字段一样只刷新Ajax更新面板,而不是所有页面?我需要什么代码?
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource1" CellPadding="4"
ForeColor="#333333" GridLines="None"
onselectedindexchanged="GridView1_SelectedIndexChanged" Width="232px">
<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>
这是更新面板的代码,当我点击GridView1中的ID时,使用Gridview2刷新更新面板:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" 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:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ProbaConnectionString %>"
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
答案 0 :(得分:0)
您需要在Page_Load()中手动将每个回发添加HyperLink作为回发触发器。也许这会解决问题..