今天要实现一个功能,就是在grid表格双击行事件中根据双击行的内容在父窗口上新增加一个选项卡,grid采用了数据库分页,在第一页时双击行没有问题,可以在父窗口上新增上选择卡,如图一;翻页到第二页,双击grid行,出现错误,无法新增选项卡,重新翻页到第一页,双击行也无法新增选项卡,错误如图二.希望能给分析一下是什么问题了
图一
图二
前端代码
- <body>
- <form id="form1" runat="server">
- <f:PageManager ID="PageManager1" runat="server" AutoSizePanelID="P1" />
- <f:Panel ID="P1" runat="server" BodyPadding="5px" ShowBorder="true" ShowHeader="false" Title="Panel" Layout="Fit">
-
- <Items>
- <f:HiddenField ID="H_tj" runat="server"></f:HiddenField>
- <f:Grid ID="DG_show" runat="server" ShowHeader="false" DataKeyNames="用户ID,试卷ID,状态,名称" AllowPaging="True" EnableRowDoubleClickEvent="True" EnableCheckBoxSelect="true" IsDatabasePaging="True">
- <Columns>
- <f:BoundField DataField="用户ID" HeaderText="用户ID" TextAlign="Left"/>
- <f:BoundField DataField="名称" HeaderText="名称" TextAlign="Center" />
- <f:BoundField DataField="得分" HeaderText="得分" TextAlign="Center" />
- <f:BoundField DataField="状态" HeaderText="状态" TextAlign="Center" />
- <f:BoundField DataField="日期" HeaderText="日期" TextAlign="Center" Width="120" DataFormatString="{0:yyyy-MM-dd}" />
- <f:LinkButtonField HeaderText="查阅" CommandName="CY" Icon="zoom" TextAlign="Center" Width="90" />
- <f:TemplateField Width="1">
- <ItemTemplate>
- <asp:TextBox ID="TextBox1" runat="server" CssClass="RowHeight"></asp:TextBox>
- </ItemTemplate>
- </f:TemplateField>
- </Columns>
- </f:Grid>
- </Items>
- </f:Panel>
- </form>
- <script type="text/javascript">
- function OpenTabUrl(url, text, codeid) {
- //如果已经存在该Tab,则刷新
- var iframeModule = window.parent.frames[codeid];
- if (iframeModule != null) {
- //如果已经打开的,则刷新页面
- iframeModule.location.reload();
- } else {
- parent.F('RegionPanel1_R_right_mainTabStrip').addTab({ id: codeid, url: url, title: text, closable: true }); //关键在于使用了parent.,找到了标签
- }
- }
- </script>
- </body>
- </html>
复制代码后端代码:
- Protected Sub DG_show_RowDoubleClick(ByVal sender As Object, ByVal e As FineUI.GridRowClickEventArgs) Handles DG_show.RowDoubleClick
- '双击打开考卷信息
- Dim guid As String = ""
- Dim xh As Integer = e.RowIndex
- Dim yhid As String = ""
- Dim sjid As String = ""
- Dim sjzt As String = ""
- Dim yhm As String = ""
- Dim url As String = ""
- yhid = DG_show.DataKeys(xh)(0)
- sjid = DG_show.DataKeys(xh)(1)
- sjzt = DG_show.DataKeys(xh)(2)
- yhm = DG_show.DataKeys(xh)(3)
- If sjzt = "已批阅" Then
- url = "kaoshi/cysj.aspx?sjid=" & sjid & "&yhid=" & yhid
- PageContext.RegisterStartupScript("OpenTabUrl('" & url & "','" & yhm & "的考卷','" & sjid + 100 & "')")
- Exit Sub
- Else
- info = " 本份试卷还没有批阅完毕,所以无法查看批阅结果及答案!"
- Alert.ShowInTop(info, "信息提示", MessageBoxIcon.Information)
- Exit Sub
- End If
- End Sub
复制代码
|