1、父窗体:
2、子窗体:
- C# code
-
<ItemTemplate> <asp:LinkButton ID="LinkButton5" runat="server" ForeColor="#000066">查看</asp:LinkButton> <asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "F_name")%>' Visible="False" Width="0px"></asp:Label> </ItemTemplate>
- C# code
-
if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton l = (LinkButton)e.Row.FindControl("LinkButton5"); Label b = (Label)e.Row.FindControl("Label2"); string Temp = b.Text.ToString(); l.Attributes.Add("onclick", "window.showModalDialog('ContractParticularData.aspx?id="+Temp+"','window','dialogWidth:880px;DialogHeight=700px;status:no;help:no;resizable:yes;');window.location='#';"); }
2、子窗体:
- HTML code
-
<tr> <td class="style3">客户名称:</td> <td class="style1"> <asp:Label ID="Label3" runat="server" Text="Label3"></asp:Label> </td> </tr>
- C# code
-
string IDStr = Request.QueryString["id"].ToString(); OleDbConnection sqlConn = DB.CreateConn(); sqlConn.Open(); string sqlStr = "select * from XXXX where F_name='" + IDStr.ToString() + "'"; OleDbCommand MyCommand = new OleDbCommand(sqlStr, sqlConn); OleDbDataReader MyReader = MyCommand.ExecuteReader(); while(MyReader.Read()) { this.Label3.Text = MyReader["XXX"].ToString(); } sqlConn.Close();
结果:子窗体数据没绑上,Label3还是显示Lable3,请问这样传值对吗?
回答:
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton l = (LinkButton)e.Row.FindControl("LinkButton5");
Label b = (Label)e.Row.FindControl("Label2");
string Temp = b.Text.ToString();
l.Attributes.Add("onclick", "window.showModalDialog('ContractParticularData.aspx?id="+Server.UrlEncode(Temp)+"','window','dialogWidth:880px;DialogHeight=700px;status:no;help:no;resizable:yes;');window.location='#';");
}