想收徒弟的留下自己的QQ      本人聪明好学,  精通ASP  现在在学asp.net想找高手做老师!学成之后免费为老师写代码!    
我QQ58022753请流下QQ号码!        想找多个老师!

解决方案 »

  1.   

    到CSDN这个大学堂来就对了,大家都互相学习,每个人既可以当老师也可以当学生!
      

  2.   

    这个问题 谁能帮我看看啊!   !!!!!!!!!!!   一点按扭就出现错误:
    未将对象引用设置到对象的实例。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
    行 69:  for(j=0;j<i;j++)
    行 70:  {
    行 71:  xieru="insert into aaa (aa) Values('"+ Request.Form["aa"][i]+ "')";
    行 72:  cmd = new OleDbCommand(xieru,conn); 
    行 73:  cmd.ExecuteNonQuery();
     源文件: d:\netweb\xiao\tianjiann.aspx.cs    行: 71 堆栈跟踪: 
    [NullReferenceException: 未将对象引用设置到对象的实例。]
       xiao.tianjiann.Button1_Click(Object sender, EventArgs e) in d:\netweb\xiao\tianjiann.aspx.cs:71
       System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       System.Web.UI.Page.ProcessRequestMain() +1277 
    代码如下:
    <%@ Page language="c#" Codebehind="tianjiann.aspx.cs" AutoEventWireup="false" Inherits="xiao.tianjiann" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <TITLE>tianjiann</TITLE>
    </HEAD>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <script language="javascript">
      function setid()
      {
      str='<br>';
      if(!window.form1.upcount.value)
       window.form1.upcount.value=1;
        for(i=1;i<=window.form1.upcount.value;i++)
         str+=''+i+'.&nbsp;姓名:<input type="text" name="aa'+i+'" value="" size="8" class="txtfld">';
      window.upid.innerHTML=str+'<br>';
      }
    </script>
    <form method="post" runat="server" id="form1">
    <table cellSpacing="0" cellPadding="0" width="380" border="0">
    <tr>
    <td bgColor="#000099">
    <table class="text2" cellSpacing="1" cellPadding="2" width="100%" align="center" border="0">
    <tr align="center" bgColor="#0066cc">
    <td class="pt9-FFFFFF" noWrap colSpan="3" height="26"><font color="#ffffff">添加小组成员 </font>
    </td>
    </tr>
    <tr bgColor="#ffffff">
    <td vAlign="baseline" noWrap align="right" width="71" bgColor="#ffffff">设定人数:</td>
    <td vAlign="baseline" width="398" bgColor="#ffffff" colSpan="2"><select class="txtfld4" onchange="setid()" id="upcount" name="upcount" runat="server">
    <option value="1" selected>1 人</option>
    <option value="2">2 人</option>
    <option value="3">3 人</option>
    <option value="4">4 人</option>
    <option value="5">5 人</option>
    <option value="6">6 人</option>
    <option value="7">7 人</option>
    <option value="8">8 人</option>
    <option value="9">9 人</option>
    <option value="10">10 人</option>
    <option value="11">11 人</option>
    <option value="12">12 人</option>
    </select></td>
    </tr>
    <tr bgColor="#ffffff">
    <td id="upid" noWrap colSpan="3" height="54">1.&nbsp;姓名: <input class="txtfld" type="text" size="8" id="aa1" runat="server" maxLength="0">&nbsp;&nbsp;&nbsp;&nbsp;
    </td>
    </tr>
    <tr bgColor="#ffffff">
    <td noWrap align="center" colSpan="3" height="26">
    <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>&nbsp;
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </form>
    </HTML>
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Data.OleDb;
    namespace xiao
    {
    /// <summary>
    /// tianjiann 的摘要说明。
    /// </summary>
    public class tianjiann : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Button Button1;
    protected System.Web.UI.HtmlControls.HtmlSelect upcount;
    protected System.Web.UI.HtmlControls.HtmlInputText aa1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    Page.DataBind(); } private void InitializeComponent()
    {
    this.Button1.Click += new System.EventHandler(this.Button1_Click); } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void Initialize()
    {    
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {

    int j=0;
    string xieru;
    OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("222.mdb"));
    OleDbCommand cmd;
    conn.Open();
    int i=Convert.ToInt32(Request.Form["upcount"]);
    for(j=0;j<i;j++)
    {
    xieru="insert into aaa (aa) Values('"+ Request.Form["aa"][i]+ "')";
    cmd = new OleDbCommand(xieru,conn); 
    cmd.ExecuteNonQuery();
    conn.Close(); }
    conn.Dispose();

    Response.Redirect("guesebook.aspx");


    }
    }
    }
      

  3.   

    asp.net表单控件的值无需用Request.Form方法来获取,如果是htmlInputText控件,直接用aa1.Value就可以获取它的值,上面的代码出错是因为Request.Form["aa"]是一个null值或者空字符串。
      

  4.   

    楼主刚刚开始学习ASP.NET,那么首先要知道ASP.NET多了什么,他其实就是把一些控件都封装了起来,用类表示.
    你要知道ASP.NET控件和HTML控件的区别,和调用方法.
    建议楼主先搞清楚这个.不要把ASP的东西 都用到这里来.