在VS2003里索取DATAGRID文本是这样的
string newBoard = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
在05里这句应该怎写啊?
string newBoard = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
在05里这句应该怎写啊?
解决方案 »
- GridView自动生成的字段,不显示日期格式数据
- 静态页跟ajax的选择
- DateTime.Now.Day.ToString().Trim(); 这样写我获得的德日期是1或2或3或4我怎么写才能是01或02或03或04?就是前面加上0
- datalist分类显示产品问题!!!
- Infragistics UltraWebTab 当Tab上文字过长,则页面出错???
- 关于页面跳转的问题
- 小妹请问!页面当中如何传多个参数!
- js操作json问题
- datagrid里的edititem如何控制宽度
- 请教:初学ASP.NET遇到的问题
- 《亲密接触ASP.NET》全书下载,要的速下,不忙的话顶下,谢谢
- 程序的调用的小问题
TextBox firstNameTextBox = (TextBox)row.Cells[1].FindControl("FirstNameTextBox");
{
txt=(TextBox)dvr.findcontrol("txtid"); string id=txt.text;
}
string newBoard = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
OleDbConnection conn=new OleDbConnection(Class.ConnString);
string sqlCom = "update news_board set Board='" + newBoard + "' where Bid="+empID;OleDbCommand cmd = new OleDbCommand(sqlCom,conn);
try
{
cmd.ExecuteNonQuery();
DataGrid1.EditItemIndex = -1;
BindDataGrid();
}
catch(Exception err)
{
Response.Write(err.ToString());
}
------------------------------------------------
03更新是上面这样写,但VS05应该怎写呢?各位帮忙?
string box = ((TextBox)row.FindControl("username")).Text;
OleDbConnection conn=new OleDbConnection(Class1.ConnString);
conn.Open();
string sqlCom = "update userreg set username='" + box + "' where id=" + categoryID;
OleDbCommand cmd = new OleDbCommand(sqlCom,conn);
try
{
cmd.ExecuteNonQuery();
GridView1.EditIndex = -1;
conn.Close();
DataGridBind();
}
catch (Exception err)
{
Response.Write(err.ToString());
}--------------------------------------------------
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:
行 86: // string newBoard = (TextBox)GridView1.Rows[1][0].Text;
行 87: GridViewRow row = GridView1.Rows[e.RowIndex];
行 88: string box = ((TextBox)row.FindControl("username")).Text;
行 89: OleDbConnection conn=new OleDbConnection(Class1.ConnString);
行 90: conn.Open();
如果用 TextBox box = ((TextBox)row.FindControl("username")).Text;
错误提示:
错误 1 无法将类型“string”隐式转换为“System.Web.UI.WebControls.TextBox” F:\homework\netbest2\WebSite\GridViewdel.aspx.cs 88 23 http://localhost/WebSite/