子页面
<ext:Grid ID="Grid1" runat="server" EnableCheckBoxSelect="true" EnableRowNumber="true"
Title="Grid" DataKeyNames="Name">
<Columns>
<ext:BoundField DataField="Name" DataFormatString="{0}" HeaderText="名称" />
<ext:TemplateField>
<ItemTemplate>
<input type="button" runat="server" id="btnSelected" value="选择2" />
</ItemTemplate>
</ext:TemplateField>
</Columns>
</ext:Grid>
后台代码
foreach (GridRow gr in Grid1.Rows)
{
System.Web.UI.HtmlControls.HtmlControl btnSelected = gr.FindControl("btnSelected") as System.Web.UI.HtmlControls.HtmlControl;
if (btnSelected != null)
{
StringBuilder sbJs = new StringBuilder();
sbJs.AppendFormat("var arr = new Array();{0}", System.Environment.NewLine);
sbJs.AppendFormat("arr[0] ='{0}';{1}", gr.DataKeys[0].ToString(), System.Environment.NewLine);
sbJs.AppendFormat("window.parent.returnValue = arr;{0}", System.Environment.NewLine);
sbJs.AppendFormat("alert(arr[0]);top.close();", System.Environment.NewLine);
btnSelected.Attributes.Add("onclick", sbJs.ToString());
}
}
接受方式
var arr= window.showModalDialog('子页面', '', 'dialogheight=600px;dialogwidth=800px;status=no;edge=raised;scrollbars=no');
arr为返回的数组。 |