点击按钮时将datalist控件中的值取出来提交,现在的问题是能取到datalist里面的控件但是不能取到控件的值。调试发现值是空的。

解决方案 »

  1.   

    Page_Loadif(!IsPostBack)
    {
       //数据绑定
    }
      

  2.   

      foreach (DataListItem d in dtSmallTask.Items)
            {
                TextBox txtSendTo1 = (TextBox)d.FindControl("txtSendTo");
                string txtsendTovalue=txtSendTo1.Text;
            }
    发现为空值在提交前txtSendTo有内容的,注意提交的按钮并不在dtSmallTask的模板内。所以ItemCommand之类的东西没考虑。请高手指教
      

  3.   

    至于if (!IsPostBack)
            {}这个存在的控件是找得到的但是就是取不到模板里面控件的值
      

  4.   

    你的模版里的控件有值吗?
    用findcontrol取不到?
    demo
     protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandSource.GetType() == typeof(Button))
            {
                    if (((Button)e.CommandSource).CommandName == "accept")
                    {
                        if (((CheckBox)e.Item.FindControl("select")).Checked)
                        {                    int id = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex].ToString());
                        int stuid = Convert.ToInt32(((Label)e.Item.FindControl("label1")).Text);
                        string stuname = ((Label)e.Item.FindControl("label2")).Text;
                        string stuadd = ((Label)e.Item.FindControl("label3")).Text;
                        SqlConnection cn = new SqlConnection(strcon);
                        SqlCommand cmd = new SqlCommand("insert into s(StuID,StuName,Stuaddurl) values('" + stuid + "','" + stuname + "','" + stuadd + "')", cn);
                        cn.Open();
                        cmd.ExecuteNonQuery();
                        SqlCommand cmd1 = new SqlCommand("delete from students where ID='" + id + "'", cn);
                        cmd1.ExecuteNonQuery();
                        cn.Close();
                        bind();
                        }
                    }
                    if (((Button)e.CommandSource).CommandName == "noaccept")
                    {
                        if (((CheckBox)e.Item.FindControl("select")).Checked)
                        {
                        int id = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex].ToString());
                        int stuid = Convert.ToInt32(((Label)e.Item.FindControl("label1")).Text);
                        string stuname = ((Label)e.Item.FindControl("label2")).Text;
                        string stuadd = ((Label)e.Item.FindControl("label3")).Text;
                        SqlConnection cn = new SqlConnection(strcon);
                        SqlCommand cmd = new SqlCommand("insert into sj(stuid,stuname,stuadd) values('" + stuid + "','" + stuname + "','" + stuadd + "')", cn);
                        cn.Open();
                        cmd.ExecuteNonQuery();
                        SqlCommand cmd1 = new SqlCommand("delete from students where ID='" + id + "'", cn);
                        cmd1.ExecuteNonQuery();
                        cn.Close();
                        bind();
                    }
                }
            }
      

  5.   

    回复6楼:
    对模板里面控件存在值。但是我提交的按钮并不在datalist这个控件里面也就是说我点击按钮的作用是循环找datalist里面控件的值并对数据进行数据库操作。至于ItemCommand事件应该是触发不到的。
      

  6.   

    <%@ Page Language="C#" AutoEventWireup="true" EnableViewState ="false" CodeFile="Default2.aspx.cs" Inherits="Default2" %> EnableViewState ="false" 有没有在页面或配置文件设置这个
      

  7.   


    <%@ Page Language="C#" AutoEventWireup="true" EnableViewState ="false" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:DataList ID="DataList1" runat="server">
               <ItemTemplate>
                <table>
                  <asp:TextBox ID="txt" runat="server" Text='<%#Eval("Name") %>'></asp:TextBox>
                </table>
               </ItemTemplate>
            </asp:DataList>
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        </div>
        </form>
    </body>
    </html>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("Name"));
                dt.Rows.Add(new object[] { "River" });
                dt.Rows.Add(new object[] { "China" });
                DataList1.DataSource = dt;
                DataList1.DataBind();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            foreach (DataListItem item in DataList1.Items)
            {
                TextBox tb = (TextBox)item.FindControl("txt");
                Response.Write(tb.Text);
            }
        }
    }
      

  8.   

    把Page命令中的 EnableViewState ="false" 删除
      

  9.   

    这个EnableViewState ="false"没有之前我也找过。
      

  10.   

    代码贴出来看看
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <table style="border-collapse:collapse;" border=1>
                <asp:DataList ID="DataList1" runat="server">
                    <ItemTemplate>
                        <tr>
                            <td>
                                <%#Eval("EmpID") %>
                            </td>
                            <td>
                               <asp:TextBox ID="txtName" runat="server" Text=<%#Eval("EmpName")%>></asp:TextBox>  
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:DataList>
            </table>
            <asp:Button ID="Button1" runat="server" Text="提交" onclick="Button1_Click" />
        </div>
        </form>
    </body>
    </html>
    public class Employee
            {
                public string EmpID { set; get; }
                public string EmpName { set; get; }
            }        protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    this.DataList1.DataSource = new System.Collections.Generic.List<Employee>()
                    { 
                          new Employee(){ EmpID="S001", EmpName="张三"},
                          new Employee(){ EmpID="S002", EmpName="李四"},
                          new Employee(){ EmpID="S003", EmpName="王五"},
                          new Employee(){ EmpID="S004", EmpName="赵六"},
                          new Employee(){ EmpID="S005", EmpName="小七"}
                    };
                    this.DataList1.DataBind();
                }
            }        protected void Button1_Click(object sender, EventArgs e)
            {
                string message = string.Empty;
                foreach (DataListItem item in this.DataList1.Items)
                {
                    TextBox tx = item.FindControl("txtName") as TextBox;
                    if (!string.IsNullOrEmpty(tx.Text))
                    {
                        message += tx.Text + "|";
                    }
                }
                Response.Write(message.TrimEnd('|'));   //输出信息
            }
      

  11.   

    按实例来说的话我的和八楼的代码差不多但是八楼的EnableViewState ="false"去掉后点击按钮提交的时候能取到文本框的值吗?
      

  12.   

     后台代码:   protected void btnSubmit_Click(object sender, EventArgs e)
        {
            foreach (DataListItem d in dtSmallTask.Items)
            {
                TextBox txtSendTo = (TextBox)d.FindControl("txtSendTo");            
                TextBox hdnTxtSendTo = (TextBox)d.FindControl("hdnTxtSendTo");
                TextBox txtCcTo = (TextBox)d.FindControl("txtCcTo");
                TextBox hdnTxtCcTo = (TextBox)d.FindControl("hdnTxtCcTo");
                TextBox txtBccTo = (TextBox)d.FindControl("txtBccTo");
                TextBox hdnTxtBccTo = (TextBox)d.FindControl("hdnTxtBccTo");
                TextBox txtstartTime = (TextBox)d.FindControl("txtstartTime");
                TextBox txtendTime = (TextBox)d.FindControl("txtendTime");
                CheckBox ckman1 = (CheckBox)d.FindControl("ckman1");
                CheckBox ckman2 = (CheckBox)d.FindControl("ckman2");
                CheckBox ckman3 = (CheckBox)d.FindControl("ckman3");
                CheckBox ckman4 = (CheckBox)d.FindControl("ckman4");
                CheckBox ckmsg1 = (CheckBox)d.FindControl("ckmsg1");
                CheckBox ckmsg2 = (CheckBox)d.FindControl("ckmsg2");
                CheckBox ckmsg3 = (CheckBox)d.FindControl("ckmsg3");
                CheckBox CheckBox1 = (CheckBox)d.FindControl("CheckBox1");
                CheckBox CheckBox2 = (CheckBox)d.FindControl("CheckBox2");
                CheckBox CheckBox3 = (CheckBox)d.FindControl("CheckBox3");
                TextBox txtTaskContent = (TextBox)d.FindControl("txtTaskContent");
                SqlParameter[] para =
                         {
                         new SqlParameter("@ZongRenWuBianHao",txtAllTaskID.Text ),
                         new SqlParameter("@RenWuBianHao",txtAllTaskName.Text ),
                         new SqlParameter("@FuZeRen",txtSendTo.Text ),
                         new SqlParameter("@StrFuZeRen",hdnTxtSendTo.Text ),
                         new SqlParameter("@XieBanRen",txtCcTo.Text ),
                         new SqlParameter("@StrXieBanRen",hdnTxtCcTo.Text ),
                         new SqlParameter("@CanYueRen",txtBccTo.Text ),
                         new SqlParameter("@StrCanYueRen",hdnTxtBccTo.Text ),
                         new SqlParameter("@KaiShiShiJian",txtstartTime.Text ),
                         new SqlParameter("@JieShuShiJian",txtendTime.Text ),
                         new SqlParameter("@TiXingFangShi1", ckman1.Checked == true ? "1" : "0"),
                         new SqlParameter("@TiXingFangShi2", ckman2.Checked == true ? "1" : "0"),
                         new SqlParameter("@TiXingFangShi3", ckman3.Checked == true ? "1" : "0"),
                         new SqlParameter("@TiXingFangShi4", ckman4.Checked == true ? "1" : "0"),
                         new SqlParameter("@FaSongFangShi1",ckmsg1.Checked == true ? "1" : "0"),
                         new SqlParameter("@FaSongFangShi2",ckmsg2.Checked == true ? "1" : "0"),
                         new SqlParameter("@FaSongFangShi3",ckmsg3.Checked == true ? "1" : "0"),
                         new SqlParameter("@TiXingSheZhi1",CheckBox1.Checked == true ? "1" : "0"),
                         new SqlParameter("@TiXingSheZhi2",CheckBox2.Checked == true ? "1" : "0"),
                         new SqlParameter("@TiXingSheZhi3",CheckBox3.Checked == true ? "1" : "0"),
                         new SqlParameter("@RenWuLeiRong",""),
                         new SqlParameter("@FuJian","")
                    
                          };            bs.Execute("Proc_Zong_FenRenWu_InsertORUpdate2", para);
            }
      

  13.   

     太多了发少点吧应该可以看的 <asp:DataList ID="dtSmallTask" runat="server" Width="901px" OnItemCommand="dtSmallTask_ItemCommand" >
                                <ItemTemplate>
                                    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; border-right: #3399cc 2px dashed; border-top: #3399cc 2px dashed; border-left: #3399cc 2px dashed; border-bottom: #3399cc 2px dashed;">
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px;">
                                                <strong>
                            会务分项:</strong></td>
                                            <td style="width: 536px; height: 30px;">
                                                <asp:TextBox ID="txtSmallTaskNM" runat="server" CssClass="InputStyle" Height="18px"
                                                      TabIndex="1"
                                                    Width="230px" ReadOnly="True" Text='<%# Eval("RenWuMingCheng") %>'></asp:TextBox>
                                                <asp:TextBox ID="txtSmallTaskID"   runat="server" CssClass="InputStyle" Height="18px"   ReadOnly="True" TabIndex="1" Width="52px" Text='<%# Eval("RenWuBianHao") %>'></asp:TextBox>
                                                <asp:TextBox ID="rowitemname" runat="server" Text="<%#(Container).ItemIndex + 1%>" CssClass="InputStyle" Height="18px" Width="84px" Visible="False"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 36px;">
                                                负责人:</td>
                                            <td style="width: 536px; height: 36px;">
                                                <asp:TextBox ID="txtSendTo" runat="server" CssClass="InputStyle" Height="30px" 
                                                     TabIndex="1" TextMode="MultiLine" Width="292px"  value="<%=SendToRealName%>" name="txtSendTo" ></asp:TextBox>&nbsp;
                                                <a style="CURSOR: hand"  onclick="dialwinprocess(<%#(Container).ItemIndex%>)"  href="javascript:void(0);">添加人员</a><asp:TextBox ID="hdnTxtSendTo" runat="server"
                                                            CssClass="InputStyle" Height="18px" TabIndex="1" TextMode="MultiLine" Width="154px"  value="<%=SendTo%>" name="hdnTxtSendTo" Text='<%# Eval("FuZeRen") %>'></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px;">
                                                协办人:</td>
                                            <td style="width: 536px; height: 30px;">
                                                <asp:TextBox ID="txtCcTo" runat="server" CssClass="InputStyle" Height="30px" TabIndex="1" TextMode="MultiLine" Width="292px"  value="<%=CcToRealName%>" name="txtCcTo" Text='<%# Eval("StrXieBanRen") %>'></asp:TextBox>&nbsp;
                                                <a onclick="window.open('AddMenber.aspx', 'newwindow', 'height=520, width=515, top=150, left=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')"><span
                                                        style="text-decoration: underline; cursor: hand;"></span></a><asp:TextBox ID="hdnTxtCcTo" runat="server"
                                                    CssClass="InputStyle" Height="18px" TabIndex="1" TextMode="MultiLine" Width="154px"   value="<%=CcTo%>" name="hdnTxtCcTo" Text='<%# Eval("XieBanRen") %>'></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px;">
                                                参阅人:</td>
                                            <td style="width: 536px; height: 30px;">
                                                <asp:TextBox ID="txtBccTo" runat="server" CssClass="InputStyle" Height="30px"  TabIndex="1" TextMode="MultiLine" Width="292px" value="<%=BccToRealName%>" name="txtBccTo" Text='<%# Eval("StrCanYueRen") %>' ></asp:TextBox>&nbsp;
                                                <a onclick="window.open('AddMenber.aspx', 'newwindow', 'height=520, width=515, top=150, left=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')"><span
                                                        style="text-decoration: underline; cursor: hand;"><asp:TextBox ID="hdnTxtBccTo" runat="server"
                                                            CssClass="InputStyle" Height="18px" TabIndex="1" TextMode="MultiLine" Width="154px"   value="<%=BccTo%>" name="hdnTxtBccTo" Text='<%# Eval("CanYueRen") %>'></asp:TextBox></span></a></td>
                                        </tr>
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px">
                                                任务时间设置:</td>
                                            <td style="width: 536px; height: 30px">
                                                <asp:TextBox ID="txtstartTime" runat="server" CssClass="inputdate"  Height="16px" name="txtstartTime" onclick="setday(this)"  ReadOnly="True" TabIndex="3" Width="154px" Text='<%# Eval("KaiShiShiJian") %>'></asp:TextBox>
                                                至&nbsp;
                                                <asp:TextBox ID="txtendTime" runat="server" CssClass="inputdate" Height="16px" name="txtendTime" onclick="setday(this)" ReadOnly="True" TabIndex="3" Width="154px" Text='<%# Eval("JieShuShiJian") %>'></asp:TextBox></td>
                                        </tr>
                                        <tr style="color: #004779">
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px">
                                                提醒接受人设置:</td>
                                            <td style="width: 536px; height: 30px" valign="middle"><asp:CheckBox ID="ckman1" runat="server" Text="发布人" Checked='<%# Eval("TiXingFangShi1").ToString()=="1" ? true:false %>' />
                                                <asp:CheckBox ID="ckman2" runat="server" Text="责任人" Checked='<%# Eval("TiXingFangShi2").ToString()=="1" ? true:false %>' />
                                                <asp:CheckBox ID="ckman3" runat="server" Text="协办人" Checked='<%# Eval("TiXingFangShi3").ToString()=="1" ? true:false %>' />
                                                <asp:CheckBox ID="ckman4" runat="server" Text="参阅人" Checked='<%# Eval("TiXingFangShi4").ToString()=="1" ? true:false %>' />                                </table>
                                </ItemTemplate>
                            </asp:DataList>
      

  14.   

      <asp:DataList ID="dtSmallTask" runat="server" Width="901px" OnItemCommand="dtSmallTask_ItemCommand" >
                                <ItemTemplate>
                                    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; border-right: #3399cc 2px dashed; border-top: #3399cc 2px dashed; border-left: #3399cc 2px dashed; border-bottom: #3399cc 2px dashed;">
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px;">
                                                <strong>
                            会务分项:</strong></td>
                                            <td style="width: 536px; height: 30px;">
                                                <asp:TextBox ID="txtSmallTaskNM" runat="server" CssClass="InputStyle" Height="18px"
                                                      TabIndex="1"
                                                    Width="230px" ReadOnly="True" Text='<%# Eval("RenWuMingCheng") %>'></asp:TextBox>
                                                <asp:TextBox ID="txtSmallTaskID"   runat="server" CssClass="InputStyle" Height="18px"   ReadOnly="True" TabIndex="1" Width="52px" Text='<%# Eval("RenWuBianHao") %>'></asp:TextBox>
                                                <asp:TextBox ID="rowitemname" runat="server" Text="<%#(Container).ItemIndex + 1%>" CssClass="InputStyle" Height="18px" Width="84px" Visible="False"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 36px;">
                                                负责人:</td>
                                            <td style="width: 536px; height: 36px;">
                                                <asp:TextBox ID="txtSendTo" runat="server" CssClass="InputStyle" Height="30px" 
                                                     TabIndex="1" TextMode="MultiLine" Width="292px"  value="<%=SendToRealName%>" name="txtSendTo" ></asp:TextBox>&nbsp;
                                                <a style="CURSOR: hand"  onclick="dialwinprocess(<%#(Container).ItemIndex%>)"  href="javascript:void(0);">添加人员</a><asp:TextBox ID="hdnTxtSendTo" runat="server"
                                                            CssClass="InputStyle" Height="18px" TabIndex="1" TextMode="MultiLine" Width="154px"  value="<%=SendTo%>" name="hdnTxtSendTo" Text='<%# Eval("FuZeRen") %>'></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px;">
                                                协办人:</td>
                                            <td style="width: 536px; height: 30px;">
                                                <asp:TextBox ID="txtCcTo" runat="server" CssClass="InputStyle" Height="30px" TabIndex="1" TextMode="MultiLine" Width="292px"  value="<%=CcToRealName%>" name="txtCcTo" Text='<%# Eval("StrXieBanRen") %>'></asp:TextBox>&nbsp;
                                                <a onclick="window.open('AddMenber.aspx', 'newwindow', 'height=520, width=515, top=150, left=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')"><span
                                                        style="text-decoration: underline; cursor: hand;"></span></a><asp:TextBox ID="hdnTxtCcTo" runat="server"
                                                    CssClass="InputStyle" Height="18px" TabIndex="1" TextMode="MultiLine" Width="154px"   value="<%=CcTo%>" name="hdnTxtCcTo" Text='<%# Eval("XieBanRen") %>'></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px;">
                                                参阅人:</td>
                                            <td style="width: 536px; height: 30px;">
                                                <asp:TextBox ID="txtBccTo" runat="server" CssClass="InputStyle" Height="30px"  TabIndex="1" TextMode="MultiLine" Width="292px" value="<%=BccToRealName%>" name="txtBccTo" Text='<%# Eval("StrCanYueRen") %>' ></asp:TextBox>&nbsp;
                                                <a onclick="window.open('AddMenber.aspx', 'newwindow', 'height=520, width=515, top=150, left=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')"><span
                                                        style="text-decoration: underline; cursor: hand;"><asp:TextBox ID="hdnTxtBccTo" runat="server"
                                                            CssClass="InputStyle" Height="18px" TabIndex="1" TextMode="MultiLine" Width="154px"   value="<%=BccTo%>" name="hdnTxtBccTo" Text='<%# Eval("CanYueRen") %>'></asp:TextBox></span></a></td>
                                        </tr>
                                        <tr>
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px">
                                                任务时间设置:</td>
                                            <td style="width: 536px; height: 30px">
                                                <asp:TextBox ID="txtstartTime" runat="server" CssClass="inputdate"  Height="16px" name="txtstartTime" onclick="setday(this)"  ReadOnly="True" TabIndex="3" Width="154px" Text='<%# Eval("KaiShiShiJian") %>'></asp:TextBox>
                                                至&nbsp;
                                                <asp:TextBox ID="txtendTime" runat="server" CssClass="inputdate" Height="16px" name="txtendTime" onclick="setday(this)" ReadOnly="True" TabIndex="3" Width="154px" Text='<%# Eval("JieShuShiJian") %>'></asp:TextBox></td>
                                        </tr>
                                        <tr style="color: #004779">
                                            <td class="ItemTitleFont" style="width: 114px; height: 30px">
                                                提醒接受人设置:</td>
                                            <td style="width: 536px; height: 30px" valign="middle"><asp:CheckBox ID="ckman1" runat="server" Text="发布人" Checked='<%# Eval("TiXingFangShi1").ToString()=="1" ? true:false %>' />
                                                <asp:CheckBox ID="ckman2" runat="server" Text="责任人" Checked='<%# Eval("TiXingFangShi2").ToString()=="1" ? true:false %>' />
                                                <asp:CheckBox ID="ckman3" runat="server" Text="协办人" Checked='<%# Eval("TiXingFangShi3").ToString()=="1" ? true:false %>' />
                                                <asp:CheckBox ID="ckman4" runat="server" Text="参阅人" Checked='<%# Eval("TiXingFangShi4").ToString()=="1" ? true:false %>' />                                </table>
                                </ItemTemplate>
                            </asp:DataList>
      

  15.   

    看下,原来你是说多行文本框取不到值
    你按如下方法给多行文本框赋值   protected void dtSmallTask_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                TextBox tb = (TextBox)e.Item.FindControl("txtSendTo");
                tb.Text = ((DataRowView)e.Item.DataItem)["Name"].ToString();
            }
        }
      

  16.   

    看了下IHandler的实例估计还是我的代码有问题,估计脚本里面清空掉了,仔细看下到时候不管怎样回复下大家。
      

  17.   

    <asp:TextBox ID="txtSendTo" runat="server" CssClass="InputStyle" Height="30px"  
      TabIndex="1" TextMode="MultiLine" Width="292px" value="<%=SendToRealName%>" name="txtSendTo" ></asp:TextBox>value="<%=SendToRealName%>" 不要用Value了,用Text
      

  18.   

    我看这些代码没啥问题了
    控件都取不到值,还是检查下配置文件有没有做全局enableviewstate设置,并在本页面page命令加上 EnableViewState="true"另外,其它页面没有这样的问题?
      

  19.   

    有没有用新的母版页,模板页是否EnableViewState = "false"
      

  20.   

    问题解决答案已于昨晚解决:我用的脚本对其进行datalist中的控件进行赋值,而且本身datalist中生成的控件为客户端控件所以如果在提交的时候服务器端时判断该控件的值是空的,是用脚本找到该控件对应的clientid在从中去取值。
      

  21.   

    http://blog.csdn.net/xianfajushi/archive/2008/11/30/3413317.aspx
      

  22.   

    取DataList中某一项中的某个控件的值,这样是吧所以项的值都取出来了!