0

当我单击 Gridview1 中的 ID 时,我该怎么做?我需要什么代码?

<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>
4

1 回答 1

0

您需要在 Page_Load() 中手动将 HyperLink 添加为每次回发的回发触发器。也许这会解决问题..

于 2012-09-11T23:37:52.270 回答