说明:点"查询"按钮打开子窗口,以GRIDVIEW显示,点每行后的选择按钮取到该行的指定单元格里的内容,传到父窗口的指定文本框中.
父窗口代码:
view plaincopy to clipboardprint?
function search(){
var obj = document.getElementById("<%=IPSName.ClientID%>").value;
window.showModalDialog("../jgctaxnet/IPSNameList.aspx?entName="+obj,window,"dialogHeight:500px;dialogWidth:700px,center:yes,resizable:no,status:no");
}
function search(){
var obj = document.getElementById("<%=IPSName.ClientID%>").value;
window.showModalDialog("../jgctaxnet/IPSNameList.aspx?entName="+obj,window,"dialogHeight:500px;dialogWidth:700px,center:yes,resizable:no,status:no");
}
view plaincopy to clipboardprint?
<input type="button" name="searchConstructUnitBt" id="searchIPSNameBt" value="查 询" runat="server" οnclick="search()" />
<input type="button" name="searchConstructUnitBt" id="searchIPSNameBt" value="查 询" runat="server" οnclick="search()" />
子窗口代码:
view plaincopy to clipboardprint?
function insertValue(bt)
{
var tblRow = bt.parentNode.parentNode;//取得父节点的父节点,这里取得该行的对象<tr>
var returnValue = tblRow.cells[0].innerText;//取得改行第一个单元格里的内容
window.dialogArguments.document.getElementById("IPSName").value = Trim(returnValue);
window.close();
}
function insertValue(bt)
{
var tblRow = bt.parentNode.parentNode;//取得父节点的父节点,这里取得该行的对象<tr>
var returnValue = tblRow.cells[0].innerText;//取得改行第一个单元格里的内容
window.dialogArguments.document.getElementById("IPSName").value = Trim(returnValue);
window.close();
}
view plaincopy to clipboardprint?
<body>
<form id="form1" runat="server">
<center>
<asp:GridView ID="GridView1" runat="server" Font-Names="宋体" CellPadding="1" AutoGenerateColumns="False" Width="100%">
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="Blue" VerticalAlign="Middle"
BackColor="White" Height="15px" Font-Size="10pt"></HeaderStyle>
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<table border="1" cellpadding="1" cellspacing="1" width="80%">
<tr>
<td align="center" valign="middle">施工单位</td>
<td align="center" valign="middle">操 作</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="left" valign="middle">
<input type="hidden" id="choosedUnityHidden" value="<%# Eval("QYMC") %>"/>
<asp:Label ID="choosedUnity" runat="server"><%# Eval("QYMC") %></asp:Label>
</td>
<td align="center" valign="middle">
<input type="button" οnclick="insertValue(this);" value="选 择" id="bt"/>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<asp:Label ID="Label" runat="server" Font-Size="Large" ForeColor="red">没有此施工单位的记录!</asp:Label>
</EmptyDataTemplate>
</asp:GridView>
</center>
</form>
</body>
<body>
<form id="form1" runat="server">
<center>
<asp:GridView ID="GridView1" runat="server" Font-Names="宋体" CellPadding="1" AutoGenerateColumns="False" Width="100%">
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="Blue" VerticalAlign="Middle"
BackColor="White" Height="15px" Font-Size="10pt"></HeaderStyle>
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<table border="1" cellpadding="1" cellspacing="1" width="80%">
<tr>
<td align="center" valign="middle">施工单位</td>
<td align="center" valign="middle">操 作</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="left" valign="middle">
<input type="hidden" id="choosedUnityHidden" value="<%# Eval("QYMC") %>"/>
<asp:Label ID="choosedUnity" runat="server"><%# Eval("QYMC") %></asp:Label>
</td>
<td align="center" valign="middle">
<input type="button" οnclick="insertValue(this);" value="选 择" id="bt"/>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<asp:Label ID="Label" runat="server" Font-Size="Large" ForeColor="red">没有此施工单位的记录!</asp:Label>
</EmptyDataTemplate>
</asp:GridView>
</center>
</form>
</body>
后台:
view plaincopy to clipboardprint?
protected void Page_Load(object sender, EventArgs e)
{
string entName = Request.QueryString["entName"];//获取请求所传的参数
string cmd_sql = "select t.QYMC from jgcuser.xkz t where t.QYMC like '%" + entName + "%'";
Config config = new Config();
DataSet ds = config.GetResult(cmd_sql);
GridView1.DataSource = ds;
GridView1.DataBind();
config.Close();
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hli33/archive/2009/08/13/4443873.aspx