StreamReader sr = new StreamReader(@"C:\1.txt", UnicodeEncoding.GetEncoding("GBK"));
string txt = sr.ReadToEnd();
textBox1.Text = txt;

解决方案 »

  1.   

    label1.Text = sr.ReadToEnd();
    或者
    textBox1.Text = sr.ReadToEnd();
      

  2.   

    晕,你也太小白了!
    label和textbox是控件名称,你要先添加控件才能用啊!
      

  3.   


    不行那你这是web的还是winfrom的?
    winform的要在窗体上面放一个Lable或者TextBox控件啊
      

  4.   

    控件添加了,在.aspx中啊,这个是写在.aspx.cs中的
      

  5.   


    不行那你这是web的还是winfrom的?
    winform的要在窗体上面放一个Lable或者TextBox控件啊
    是Web
      

  6.   


    不行那你这是web的还是winfrom的?
    winform的要在窗体上面放一个Lable或者TextBox控件啊
    是Web页面上加上下面代码
    <asp:TextBox ID="TextBox1" runat="server" Height="105px" TextMode="MultiLine" 
    Width="320px"></asp:TextBox> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
      

  7.   


    不行那你这是web的还是winfrom的?
    winform的要在窗体上面放一个Lable或者TextBox控件啊
    是Web页面上加上下面代码
    <asp:TextBox ID="TextBox1" runat="server" Height="105px" TextMode="MultiLine" 
    Width="320px"></asp:TextBox> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    我这个写在.aspx中了
      

  8.   

    看看Label ID="Label1"是否匹配
      

  9.   


    不行那你这是web的还是winfrom的?
    winform的要在窗体上面放一个Lable或者TextBox控件啊
    是Web页面上加上下面代码
    <asp:TextBox ID="TextBox1" runat="server" Height="105px" TextMode="MultiLine" 
    Width="320px"></asp:TextBox> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    我这个写在.aspx中了你确定是写在当前页面中了?
      

  10.   


    不行那你这是web的还是winfrom的?
    winform的要在窗体上面放一个Lable或者TextBox控件啊
    是Web页面上加上下面代码
    <asp:TextBox ID="TextBox1" runat="server" Height="105px" TextMode="MultiLine" 
    Width="320px"></asp:TextBox> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    我这个写在.aspx中了你确定是写在当前页面中了?
      

  11.   


    不行那你这是web的还是winfrom的?
    winform的要在窗体上面放一个Lable或者TextBox控件啊
    是Web页面上加上下面代码
    <asp:TextBox ID="TextBox1" runat="server" Height="105px" TextMode="MultiLine" 
    Width="320px"></asp:TextBox> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    我这个写在.aspx中了你确定是写在当前页面中了?
    是的,我写在WebForm2.aspx和WebForm2.aspx.cs中的
      

  12.   

    你在这个方法外面点一下这个控制看能不能点出来 this.TextBox.Text=""看下能不能点的出来
      

  13.   

    不能显示的是TextBox1不存在你仔细对下,有加红的代码么?
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
      

  14.   

    不能显示的是TextBox1不存在你仔细对下,有加红的代码么?
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        
        <td> 
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
      
        </td>
      

  15.   

    不能显示的是TextBox1不存在你仔细对下,有加红的代码么?
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    应该是我前面写的读出文本的代码有问题吧
      

  16.   


    不行那你这是web的还是winfrom的?
    winform的要在窗体上面放一个Lable或者TextBox控件啊
    不行那你这是web的还是winfrom的?
    winform的要在窗体上面放一个Lable或者TextBox控件啊
    protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //连接数据库
                string sqlconnstr = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
                DataSet ds = new DataSet();
                using (SqlConnection sqlconn = new SqlConnection(sqlconnstr))
                {
                    String ztid = Request.QueryString["ztID"];
                    //读取文件
                    SqlDataAdapter sqld = new SqlDataAdapter("select useid,ctTime,ctZw,floor from congtie where  ztID='" + ztid.ToString() + "' ", sqlconn);
                    
                    DataTable dt = new DataTable();
                    sqld.Fill(dt);
                    foreach (DataRow dr in dt.Rows)
                    {
                        StreamReader sr = new StreamReader(dr["ctZw"].ToString());
                        Response.Write(sr.ReadToEnd());
                        string txt = sr.ReadToEnd();
                        this.TextBox2.Text = txt;
                        sr.Close();
                    }
                    sqld.Fill(ds, "tabct");
                }
                DataList1.DataSource = ds.Tables["tabct"].DefaultView;
                DataList1.DataBind();
            }    }ctZw在数据库中存放文本的路径,想给它读出来,显示在Label或者TextBox中
      

  17.   

    把你aspx代码全贴出来。form里啊
      

  18.   

    把你aspx代码全贴出来。无力了。
      

  19.   

    把你aspx代码全贴出来。无力了。
      

  20.   

     <form id="form1" runat="server" > 
        <div>
         <asp:DataList ID="DataList1" runat="server"  style="margin-top: 0px" Width="718px" 
                Height="278px" align="center" 
               >
        <ItemTemplate>
       <table width="500"  border="1" >
        <tr> 
        <td width="100" rowspan="3" class="manage_lines1"> 
          用户:<%#Eval("useid ")%></td>
        <td>
        <table width="400" border="1">
        <tr><td>
         发表于:<%#Eval("ctTime")%># <%#Eval("floor")%>
        </td>
        </tr>
        <tr>
           
        <td> 
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
      
        </td>
        </tr>
        <tr>
        <td  align="right">
       <asp:LinkButton ID="LinkButton1" runat="server"   Text="回复" href="#TextBox1" />
       <asp:Button ID="Button2" runat="server"  OnClick="Button2_Click" Text="赞" />
        </td>
        </tr>
        </table>
        </td>
        </tr>
        </table>
       
        </ItemTemplate>
        </asp:DataList>
         </div>     <div>
        <table border="1" style="height:240px; width: 500px"align="center">
        <tr >
        <td>
        <asp:TextBox ID="TextBox1" runat="server"  Width="500" Height="200" TextMode="MultiLine"></asp:TextBox>
        </td>
        </tr>
        <tr align="right">
        <td  class="auto-style1">
            <asp:Button ID="Button3" runat="server"   OnClick="Button3_Click" Text="发帖" />
            <asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="取消" 
                Height="21px" />
        </td>
        </tr>
         </table>
        </div>    </form>
      

  21.   

    看下aspx对应的designer.cs文件中是不是缺少Label和TextBox的定义,缺少的话加上去