想收徒弟的留下自己的QQ 本人聪明好学, 精通ASP 现在在学asp.net想找高手做老师!学成之后免费为老师写代码!
我QQ58022753请流下QQ号码! 想找多个老师!
我QQ58022753请流下QQ号码! 想找多个老师!
解决方案 »
- discuz NT版,想新建一个门户页,需要怎么做,步骤是?
- 给工程分配资源相当于给用户角色分配相应的权限,一个DropDownList 一个CheckBoxList
- web.config里的全部元素都显示未找到架构信息,是什么意思?
- 在aps.net中,怎么使用https进行加密
- 经典非原创,网页常用Javascript
- 给想学ASP.NET的朋友.---北大青鸟 ASP.net C#由浅入深视频教程,来的都有分!
- 有关datagrid的列宽设置
- CS0103: 当前上下文中不存在名称“Tools”
- 内存中的图片怎么直接显示到WEB控件
- 保存成EXCEL,word的老问题
- 再次100分出击~~~~~~~~~REPEATER中页码显示的C#代码有吗??
- DataGrid里隐藏一个控件
未将对象引用设置到对象的实例。
说明: 执行当前 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+'. 姓名:<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. 姓名: <input class="txtfld" type="text" size="8" id="aa1" runat="server" maxLength="0">
</td>
</tr>
<tr bgColor="#ffffff">
<td noWrap align="center" colSpan="3" height="26">
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</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");
}
}
}
你要知道ASP.NET控件和HTML控件的区别,和调用方法.
建议楼主先搞清楚这个.不要把ASP的东西 都用到这里来.