父窗口:
弹出模态窗口的javascript
function ComplementMaintenanceInfoWindows(InfoID)
{
debugger;
sRet4=window.showModalDialog("ComplementMaintenanceInfoUI.aspx?InfoID="+InfoID+"&time="+Date(),"补单","scrollbars=no;resizable=yes;help=no;status=no;dialogHeight=450px;dialogwidth=580px;center=yes");
if(sRet4=="refresh") {
window.location.href =window.location.href ;
}
}
其中点击GridView的ButtonField"补单",将会弹出模态窗口
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
BackColor="White" BorderColor="Black" PageSize="15" DataKeyNames ="InfoID"
onpageindexchanging="GridView1_PageIndexChanging"
onrowdatabound="GridView1_RowDataBound" >
<Columns>
<asp:BoundField DataField="WorkNo" HeaderText="单号"> </asp:BoundField>
<asp:BoundField DataField="Status" HeaderText="工单状态"> </asp:BoundField>
<asp:BoundField DataField="UserName" HeaderText="维修工程师"> </asp:BoundField>
<asp:BoundField DataField="CUnits" HeaderText="客户单位"> </asp:BoundField>
<asp:ButtonField CommandName="Print" Text="补单" HeaderText="补单"> </asp:ButtonField>
</Columns>
<PagerStyle HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="#CCCCCC" />
</asp:GridView>
//后台cs绑定
if (e.Row.RowType.Equals(DataControlRowType.DataRow))
{
LinkButton btDatail = (LinkButton)e.Row.Cells[4].Controls[0];
btDatail.Attributes.Add("onclick", "ComplementMaintenanceInfoWindows(" + this.GridView1.DataKeys[e.Row.RowIndex].Values["InfoID"].ToString() + ")");
}
模态窗口
Response.Write(" <script>alert('保存成功!');window.returnValue='refresh';window.close(); </script>");
问题是:在关闭模态窗口的时候刷新不到GridView,但是这种写法对页面上的按钮就没有问题。我试过这种
Button btDatail = (Button)e.Row.Cells[4].Controls[0];但是,会提示无法转换。
-
已移动
肖小勇Moderator
2010年3月4日 6:17
asp.net 相关问题 (发件人:.NET Framework 一般性问题讨论区)