我有一个GridView,它有一个控件。当我点击这个LinkButton(父页面的GridView)时,我会打开一个LinkButton
我打开一个弹出窗口,里面还有一个GridView和一个带LinkButtons
的列现在当我点击这个LinkButton
(弹出GridView)时...... PopUp关闭,名称或文本值传递给父页面..我有这么多工作。我不想将我从PopUp GridView检索到的值设置为最初调用PopUp的父页面的GridView LinkButton
。
父页面
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">click</asp:LinkButton>
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<script type="text/javascript">
function FillTextFromPopup(text) {
alert(text);
}
</script>
* 父页面的代码*
protected void Page_Load(object sender, EventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Patient", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
table.Rows.Add(25, "Indocin", "David", DateTime.Now);
table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
GridView1.DataSource = table;
GridView1.DataBind();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
int index = gvRow.RowIndex;
LinkButton lnk = (LinkButton)gvRow.FindControl("LinkButton1");
string id = lnk.ID;
Session["myID"] = id;
string myScript;
myScript = "<script>window.open('PopUpTest1.aspx?',null,'height=750, width=1024,status= no,resizable= no, scrollbars=yes,toolbar=no,location=no,menubar=no'); </script>";
ScriptManager.RegisterStartupScript(this, this.GetType(), "pop", myScript, false);
}
PopUp Page
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click1"
Text='<%# Eval("name") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
PopUp Page的背后代码
protected void Page_Load(object sender, EventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("a", typeof(int));
table.Columns.Add("b", typeof(string));
table.Columns.Add("c", typeof(string));
table.Columns.Add("d", typeof(DateTime));
table.Columns.Add("name", typeof(string));
table.Rows.Add(1, "Indocin1", "David1", DateTime.Now,"arbaaz");
table.Rows.Add(2, "Enebrel1", "Sam1", DateTime.Now,"Ravish");
table.Rows.Add(3, "Hydralazine1", "Christoff1", DateTime.Now,"Gulzar");
table.Rows.Add(4, "Combivent1", "Janet1", DateTime.Now,"Anas");
table.Rows.Add(5, "Dilantin1", "Melanie1", DateTime.Now,"Danish");
GridView1.DataSource = table;
GridView1.DataBind();
}
protected void LinkButton1_Click1(object sender, EventArgs e)
{
GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
int index = gvRow.RowIndex;
LinkButton lnk = (LinkButton)gvRow.FindControl("LinkButton1");
string myScript=lnk.Text;
string aaa = "javascript:window.opener.FillTextFromPopup('"+myScript+"'); window.close();";
ScriptManager.RegisterStartupScript(this, GetType(), ClientID, aaa, true);
}
答案 0 :(得分:0)
有两种方法可以更改父页面网格上的某些值。