会话参数在重新加载之前不会通过

时间:2014-09-23 17:31:09

标签: asp.net updatepanel webdatagrid

我有一个会话参数,它从webgridview1获取单元格数据并使用它将信息传递到webgridview2, 会话正在正确更新,但直到我手动点击重新加载按钮才会填充第二个webgridview

Public Sub WebDataGrid1_CellSelectionChanged(sender As Object, e As Infragistics.Web.UI.GridControls.SelectedCellEventArgs) Handles WebDataGrid1.CellSelectionChanged
    Dim pressName = e.CurrentSelectedCells(0).Text
    Session("PressName") = pressName
    UpdatePanel1.Update()
End Sub

我尝试了一个更新面板,但这不是正常工作 Response.Redirect打开一个空页面,其中gridviews已经消失了 我怎样才能重新加载我的页面,或者让会话再次进入webdatagrid?

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
   <ContentTemplate>
                <ig:WebDataGrid ID="WebDataGrid1" runat="server" Width="400px" 
                    AutoGenerateColumns="False" DataSourceID="SqlDataPressNames">
                    <Columns>
                        <ig:BoundDataField DataFieldName="RecordNumber" Hidden="True" 
                            Key="RecordNumber">
                            <Header Text="RecordNumber" />
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="PressName" Key="PressName">
                            <Header Text="PressName" />
                        </ig:BoundDataField>
                        <ig:BoundCheckBoxField DataFieldName="PressActive" Key="PressActive" >
                            <Header Text="PressActive" />
                        </ig:BoundCheckBoxField>
                    </Columns>
                    <Behaviors>
                        <ig:Selection>
                            <AutoPostBackFlags CellSelectionChanged="True" />
                        </ig:Selection>
                    </Behaviors>
                </ig:WebDataGrid>
                <asp:SqlDataSource ID="SqlDataPressNames" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:masterConnectionString %>" 
                    SelectCommand="SELECT [RecordNumber], [PressName], [PressActive] FROM [PressInfoNew] ORDER BY [PressName]">
                </asp:SqlDataSource>


                       <ig:WebDataGrid ID="WebDataGrid2" runat="server" AutoGenerateColumns="False" 
                           DataSourceID="SqlDataPressInfo" Width="400px">
                           <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="SqlDataPressInfo" 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>
</asp:Content>

1 个答案:

答案 0 :(得分:0)

您所显示的代码中没有第二个网格视图的DataBind。试试这个

Public Sub WebDataGrid1_CellSelectionChanged(sender As Object, e As Infragistics.Web.UI.GridControls.SelectedCellEventArgs) Handles WebDataGrid1.CellSelectionChanged
    Dim pressName = e.CurrentSelectedCells(0).Text
    Session("PressName") = pressName
    WebDataGrid2.DataBind()
End Sub