用户控件引用为空问题 (asp .net)

一个关于引用为空的问题

10-06

各位大虾,小弟我刚开始看ASP.NET,有点不懂的,问问大家:rnrnusing System.Collections;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnusing System.Data.SqlClient;rnrnpublic partial class JustForFun : System.Web.UI.Pagernrn protected void Page_Load(object sender, EventArgs e)rn rn if (!Page.IsPostBack)rn rn myConnection.ConnectionString = myConnectionString;rn myGridView.EmptyDataText = "";rn string cmdString = "SELECT * FROM Products WHERE SupplierID=1";rn SqlDataAdapter myDataAdapter = new SqlDataAdapter(cmdString, myConnection);rnrn using (myConnection)rn rn myConnection.Open();rn myDataAdapter.Fill(myDataSet, "Products");rnrn myGridView.DataSource = myDataSet.Tables[0];rn myGridView.DataBind();rn rn rn rn rn rnrnrn protected void myGridView_RowEditing(object sender, GridViewEditEventArgs e) //生成Edit事件时激发rn rn using (myConnection)rn rn myConnection.Open();rn myDataAdapter.Update(myDataSet); //这段代码运行不了。 myDataAdapter这个引用为空,但我在上文实例化过了,这是为什么?rn rn rn rnrn private SqlDataAdapter myDataAdapter;rn private DataSet myDataSet = new DataSet("MyDataSet");rn private string myConnectionString = ConfigurationManager.ConnectionStrings["NORTHWINDCONNECTIONSTRING"].ConnectionString;rn private static SqlConnection myConnection = new SqlConnection();rnrnrnrnrn问题在代码里。。rnrn请各位指教!rn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试