当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·一个关于链表的问题    »显示摘要«
    摘要: 代码如下: #include <alloc.h> #include "stdio.h" struct node {long num; float grade; struct node *next; }; struct node *creatlink() {int k; long nn; struct node *head,*p,*q; head=......
 ·求 database    »显示摘要«
    摘要: 求 database_access_enu.msm 文件一份,发到信箱及送100分,在线结帐! zzc205@wangyu.org 谢谢! ......


关于动态添加的控件取值问题

在动态添加的一个Table中的一个TableCell中添加一个TextBox加到From后如何在提交后获得TextBox中的值?  
  代码如下:  
  <%@Page   language="C#"   debug=true   %>  
  <%@import   NameSpace="System.IO"   %>  
  <script   runat=server>  
   
  void   Page_Load(object   sender,System.EventArgs   e){  
   
  if(IsPostBack){  
  TextBox   txt1=   (TextBox)t.Rows[0].Cells[1].FindControl("foldername");//找不到TextBox的值  
  Response.Write((string)txt.Text);  
  }  
   
  Table   t   =new   Table();  
  TableRow   tr   =new   TableRow();  
  TableCell   tc_txt=new   TableCell();  
  TableCell   tc_controls=new   TableCell();  
  TableCell   tc_button=new   TableCell();  
   
  tc_txt.Text="创建文件夹";  
  TextBox   txt=new   TextBox();  
  txt.ID="foldername";  
  tc_controls.Controls.Add(txt);  
   
  Button   bt=new   Button();  
  bt.Text="提交";  
  tc_button.Controls.Add(bt);  
   
  tr.Cells.Add(tc_txt);  
  tr.Cells.Add(tc_controls);  
  tr.Cells.Add(tc_button);  
   
  t.Rows.Add(tr);  
   
  tc_txt.Dispose();  
  tc_controls.Dispose();  
  tc_button.Dispose();  
  tr.Dispose();  
  txt.Dispose();  
  form1.Controls.Add(t);  
   
  }  
  </SCRIPT>  
  <html>  
  <head>  
  <title></title>  
  </head>  
  <body>  
  <form   id=form1   runat=server>  
   
  </form>  
  </body>  
  </html>

NO.1   作者: beyond_xiruo

你确定你的控件在Cells[1]吗?  
  if(IsPostBack)  
  -->  
  if(!IsPostBack)

NO.2   作者: panyee

改成这样就可以了  
   
  <%@Page   language="C#"   debug=true   %>  
  <%@import   NameSpace="System.IO"   %>  
  <script   runat=server>  
  Table   t   =   null;  
  void   Page_Load(object   sender,System.EventArgs   e){  
   
   
   
  t   =new   Table();  
   
   
  TableRow   tr   =new   TableRow();  
  TableCell   tc_txt=new   TableCell();  
  TableCell   tc_controls=new   TableCell();  
  TableCell   tc_button=new   TableCell();  
   
  tc_txt.Text="创建文件夹";  
  TextBox   txt=new   TextBox();  
  txt.ID="foldername";  
  tc_controls.Controls.Add(txt);  
   
  Button   bt=new   Button();  
  bt.Text="提交";  
  bt.Click   +=   new   System.EventHandler(this.Button1_Click);  
  tc_button.Controls.Add(bt);  
   
  tr.Cells.Add(tc_txt);  
  tr.Cells.Add(tc_controls);  
  tr.Cells.Add(tc_button);  
   
  t.Rows.Add(tr);  
   
  tc_txt.Dispose();  
  tc_controls.Dispose();  
  tc_button.Dispose();  
  tr.Dispose();  
  txt.Dispose();  
  form1.Controls.Add(t);  
   
  }  
  void   Button1_Click(Object   sender,   EventArgs   e)  
  {  
  TextBox   txt1=   (TextBox)t.Rows[0].Cells[1].FindControl("foldername");  
  Response.Write((string)txt1.Text);  
   
  }  
  </SCRIPT>  
  <html>  
  <head>  
  <title></title>  
  </head>  
  <body>  
  <form   id=form1   runat=server>  
  <div   id=div1   runat=server></div>  
  </form>  
  </body>  
  </html>  
 


    摘要: 评定中级职称需要两篇论文, 我有论文但没有发表过, 这些论文拿出来不行吗? 有谁知道那里可以很快地发表出自己的论文? 谢谢! ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE