父页面中的弹出子页面 [英] Pop-up Child page from Parent page
问题描述
我有一个父页面,我从DropdownList中选择公司名称。公司名称来自数据库。如果我想添加一个新公司,我需要一个子页面,我可以在其中添加一个新公司到我的数据库,并在父页面的DropdownList中获取新公司。
如何使用ASP.net和C#执行此操作?请帮助或给我一些示例链接。
I have a Parent page where I select Company name from a DropdownList. The company name is from the database. If I want to add a new company, I need a child page where I can add a new company to my database and get the new one in my DropdownList on the parent page.
How can I do this with ASP.net and C#? Please help or give me some links to examples.
推荐答案
创建一个从用户那里获取所需信息的表单 - 例如将其命名为frmCompanyDetail。
添加一个OK和一个Cancel按钮,并在设计器中设置这些属性:
表格:
Create a form which gets the required info from the user - call it frmCompanyDetail for example.
Add an OK and an Cancel button, and in the designer set these properties:
Form:
StartPosition CenterParent
ShowInTaskbar False
AcceptButton Your OK button
CancelButton Your Cancel Button
OK按钮:
OK Button:
DialogResult OK
取消按钮:
Cancel Button:
DialogResult Cancel
并将相关属性添加到表单中以传输信息。
在您的父页面中,添加以下代码:
And add the relevant Properties to your form to transfer the information.
In your Parent page, add this code:
frmCompanyDetail nc = new frmCompanyDetail();
if (nc.ShowDialog() == DialogResult.OK)
{
// Use nc properties to retrieve the data and save to the DB
...
}
如果您这样做,并实现了从表单控件传输信息的特性,您也可以使用相同的frmCompanyDetail来显示和/或更改公司信息。
If you do it like this, and implement the proiperties to transfer the info to and from the form controls, you can also use the same frmCompanyDetail to display and / or change company information later.
这篇关于父页面中的弹出子页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!