Please read this article:Creating a Fully Editable DataGrid
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=813
--------------------------------
AspNetPager 免费分页控件4.0版发布,欢迎下载使用:http://www.webdiyer.com
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=813
--------------------------------
AspNetPager 免费分页控件4.0版发布,欢迎下载使用:http://www.webdiyer.com
解决方案 »
- DataTable的操作问题
- asp连接oracle数据库无法查询
- DropDownList 使某个值的背景深色
- Asp.net2 一个验证问题,望指教
- 【救命啊,我的VS2005有这么个问题,有谁知道怎么解决么?先谢过了】
- 我想用dataGrid去实现以下功能请大虾指教,谢谢!
- 快来帮帮我
- 关于访问ORACLE的BLOB字段的问题
- 如何实现动态生成Word文档?
- 关于SharePoint2007中WebPart的问题
- 怎样在客户端用file field控件浏览图片
- 使用框架页,一父页中frameset中有左右两个页,不知两个子页中用asp.net建的cookie值是否在父页和另一框架中的页是否同要有效?
private void myDataGrid_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
myDataGrid.EditItemIndex=e.Item.ItemIndex;
BindDataGrid();
}private void myDataGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
TextBox ctrlData1 = (TextBox)e.Item.Cells[1].Controls[0];
TextBox ctrlData2 = (TextBox)e.Item.Cells[2].Controls[0];
TextBox ctrlData3 = (TextBox)e.Item.Cells[3].Controls[0];
TextBox ctrlData4 = (TextBox)e.Item.Cells[4].Controls[0];
string qq=ctrlData4.Text;
TextBox ctrlData5 = (TextBox)e.Item.Cells[5].Controls[0];
//string ctrlData5 = e.Item.Cells[5].Text; string ConnectString="data source=MATAA;initial catalog=plantask;persist security info=False;user id=sa;password=pppp;workstation id=MATAA;packet size=4096";
SqlConnection cn=new SqlConnection(ConnectString);
cn.Open();
//string strsql="update plan1 set projectname='"+ctrlData1.Text+"',"+"principal='"+ctrlData2.Text+"',"+"foreseestart='"+ctrlData3.Text+"',"+"foreseeend='"+ctrlData4.Text+"',"+"content='"+ctrlData5+"'where projectno='"+e.Item.Cells[0].Text+"'";
string strsql="UPDATE plan1 SET projectname='"+ctrlData1.Text+"',principal='"+ctrlData2.Text+"',foreseestart='"+ctrlData3.Text+"',foreseeend='"+ctrlData4.Text+"',content='"+ctrlData5.Text+"' where projectno='"+e.Item.Cells[0].Text+"'";
//string strsql="update plan1 set projectname='"+ctrlData1.Text+"',principal='ctrlData2.',foreseestart='"+ctrlData3.Text+"',foreseeend='"+ctrlData4.Text+"',content='"+ctrlData5.Text+"'where projectno='"+e.Item.Cells[0].Text+"'";
SqlCommand cmd=new SqlCommand(strsql,cn);
cmd.ExecuteNonQuery();
cn.Close();
myDataGrid.EditItemIndex=-1;
BindDataGrid();
}
private void myDataGrid_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
myDataGrid.EditItemIndex=-1;
BindDataGrid();
}