ASP。net操作数据库问题 急求大佬解答一下
在用ASP编辑Mysql的数据库增删改查功能 本人刚接触asp.net,大神勿喷
有以下问题请教:
1、点击编辑 编辑数据后

如图 点击更新 错误是未实例化 System.NullReferenceException:“未将对象引用设置到对象的实例。”
更新代码如下:
protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
con = new MySqlConnection(strCon);
string sqlstr1 = "update pricr set pricr_id='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[0].FindControl("TextBox"))).Text.ToString().Trim() + "',price_max='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[1].FindControl("TextBox"))).Text.ToString().Trim() + "',price_min='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[2].FindControl("TextBox"))).Text.ToString().Trim() + "',price_time='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[3].FindControl("TextBox"))).Text.ToString().Trim() + "', price_goodid='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[4].FindControl("TextBox"))).Text.ToString().Trim() + "' where price_id='"
+ GridView2.DataKeys[e.RowIndex].Value.ToString() + "'";
com = new MySqlCommand(sqlstr1, con);
con.Open();
com.ExecuteNonQuery();
con.Close();
GridView2.EditIndex = -1;
bind();
}
是哪里有问题那 报错的位置是红色部分 更新代码有问题吗?
2、怎么在网页中点击添加按钮 会弹出输入框 然后赋值给GridView的每一列中 并保存到Mysql数据库
希望有大佬能解答一下疑惑
成长的道路漫长,学无止境。
有以下问题请教:
1、点击编辑 编辑数据后

如图 点击更新 错误是未实例化 System.NullReferenceException:“未将对象引用设置到对象的实例。”
更新代码如下:
protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
con = new MySqlConnection(strCon);
string sqlstr1 = "update pricr set pricr_id='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[0].FindControl("TextBox"))).Text.ToString().Trim() + "',price_max='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[1].FindControl("TextBox"))).Text.ToString().Trim() + "',price_min='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[2].FindControl("TextBox"))).Text.ToString().Trim() + "',price_time='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[3].FindControl("TextBox"))).Text.ToString().Trim() + "', price_goodid='"
+ ((TextBox)(GridView2.Rows[e.RowIndex].Cells[4].FindControl("TextBox"))).Text.ToString().Trim() + "' where price_id='"
+ GridView2.DataKeys[e.RowIndex].Value.ToString() + "'";
com = new MySqlCommand(sqlstr1, con);
con.Open();
com.ExecuteNonQuery();
con.Close();
GridView2.EditIndex = -1;
bind();
}
是哪里有问题那 报错的位置是红色部分 更新代码有问题吗?
2、怎么在网页中点击添加按钮 会弹出输入框 然后赋值给GridView的每一列中 并保存到Mysql数据库
希望有大佬能解答一下疑惑
成长的道路漫长,学无止境。
...全文
相关推荐
在数据库‘master’中拒绝CREATE DATABASE权限问题的解决方法
今天使用Linq To SQL,要求判断数据库是否存在,不存在是自动创建数据库。
asp.net 操作SQLite数据库(操作Demo )
分多了点,可是这是兄弟花了3天时间整出来了,给大家分享
asp.net英语听说 教学系统 教学平台
大学英语听说教学平台系统从两种用户角度进行功能划分。 1、学生部分:新闻查看;系统公告查看;用户注册;留言答疑;在线视听查看;教学资源下载。教学资源。 2、管理员部分:管理员帐号管理;编辑新闻相关内容;编辑资料下载;教学资源管理;留言管理。
ASP.NET常见问题解答
网站开发中的常见问题,适用初步开发网站者
基于C#+Asp.net版的SqlManagement在线数据管理系统源码
基于C#+Asp.net版的SqlManagement在线数据管理系统源码


