更新面板不绑定数据

时间:2014-09-22 20:24:18

标签: asp.net vb.net updatepanel webdatagrid

我有一个gridview,当你点击一个单元格时,它会填充另一个gridview,其中一个会话参数从gridview1传递到gridview2 我放置了一个更新面板,从gridview1获取参数,然后更新为重新绑定gridview2 但是,更新时gridview不会重新绑定

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
              <ContentTemplate>

                   <ig:WebDataGrid ID="WebDataGrid2" runat="server" Width="400px" 
                       AutoGenerateColumns="False" DataSourceID="SqlDataTesting2">
                       <Columns>
                           <ig:BoundDataField DataFieldName="PressName" Key="PressName">
                               <Header Text="PressName" />
                           </ig:BoundDataField>
                           <ig:BoundDataField DataFieldName="MinWidth" Key="MinWidth">
                               <Header Text="MinWidth" />
                           </ig:BoundDataField>
                           <ig:BoundDataField DataFieldName="MinHeight" Key="MinHeight">
                               <Header Text="MinHeight" />
                           </ig:BoundDataField>
                           <ig:BoundDataField DataFieldName="MaxWidth" Key="MaxWidth">
                               <Header Text="MaxWidth" />
                           </ig:BoundDataField>
                           <ig:BoundDataField DataFieldName="MaxHeight" Key="MaxHeight">
                               <Header Text="MaxHeight" />
                           </ig:BoundDataField>
                       </Columns>
                   </ig:WebDataGrid>
                   <asp:SqlDataSource ID="SqlDataTesting2" runat="server" 
                       ConnectionString="<%$ ConnectionStrings:masterConnectionString %>" 
                       ****SelectCommand="SELECT [PressName], [MinWidth], [MinHeight], [MaxWidth], [MaxHeight] FROM [PressInfoNew] WHERE ([PressName] = @PressName) ORDER BY [PressName]">****
                       <SelectParameters>
                           <asp:SessionParameter Name="pressName" SessionField="pressName" Type="String" />
                       </SelectParameters>
                   </asp:SqlDataSource>
               </ContentTemplate>
               </asp:UpdatePanel>

Public Sub WebDataGrid1_CellSelectionChanged(sender As Object,e As Infragistics.Web.UI.GridControls.SelectedCellEventArgs)处理WebDataGrid1.CellSelectionChanged         Dim pressName = e.CurrentSelectedCells(0).Text         Session(“pressName”)= pressName         WebDataGrid2.DataBind()     结束子

Public Sub UpdatePanel1_Load(sender As Object, e As System.EventArgs) Handles UpdatePanel1.PreRender
    WebDataGrid1.DataBind()
End Sub

1 个答案:

答案 0 :(得分:0)

尝试将GridView1放在GRidview2的同一个UpdatePanel

从SqlDataTesting2中删除select命令,然后在WebDataGrid1_CellSelectionChanged中删除

SqlDataTesting2.selectcommand="SELECT [PressName], [MinWidth], [MinHeight], [MaxWidth], [MaxHeight] FROM [PressInfoNew] WHERE ([PressName] = pressName ) ORDER BY [PressName]"

    SqlDataTesting2.databind()

    WebDataGrid2.DataBind()