改变gridview,利用button写入数据库 利用两个联动下拉框作为条件。选出数据。用gridview显示出来。在对GRIDVIEW进行了一些编辑。两个radiobutton。一个DDL 。一个TEXTBOX。如图,我点下面的button把gridview中的值。传到数据库的另外一个表中、这个该如何实现。谢谢!~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) //更新 { SqlConnection c = gc(); c.Open(); string n = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim(); Label1.Text= GridView1.Rows[e.RowIndex].Cells[3].Text.ToString(); string s = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.Trim(); string h = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.Trim(); string id = GridView1.DataKeys[e.RowIndex].Value.ToString(); string sql = "update tb_StuInfo set stuName='" + n + "',stuSex= '" + s + "',stuHobby= '" + h + "' where stuID="+Convert.ToInt32(id); SqlCommand cmd = new SqlCommand(sql, c); cmd.ExecuteNonQuery(); c.Close(); GridView1.EditIndex = -1; b();希望对你有帮助 这个和你的情况差不多 我只有2列保存 是第3 和4列的textbox http://www.ie512.com/news.aspx?id=205&no=1国外空间,打开有点慢,看看有没有你要的思路 这个问题解决了吧?用findcontrol. wxr0323是否可以加你的联系方式?有很多问题想请教你。。 asp.net 如何做一个简单的二级联动下菜单 如何压缩网站? 求这样的一个正则写法 保存JS创建的checkbox的选项。。 关于GridView控件的使用,能将表转个顺序吗? 尖括号 和百分号里的脚本是什么意思?如<% ....%>? 外部DLL项目 读取网站主程序的配置文件问题 创建动态aspx页面???? vs2005在哪里建web复合控件呀? .NET 2003不能debug,好像是权限问题,求助。。。 服务器更新怎么处理缓存的 ASP.NET
{
SqlConnection c = gc();
c.Open();
string n = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim();
Label1.Text= GridView1.Rows[e.RowIndex].Cells[3].Text.ToString();
string s = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.Trim();
string h = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.Trim();
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
string sql = "update tb_StuInfo set stuName='" + n + "',stuSex= '" + s + "',stuHobby= '" + h + "' where stuID="+Convert.ToInt32(id);
SqlCommand cmd = new SqlCommand(sql, c);
cmd.ExecuteNonQuery();
c.Close();
GridView1.EditIndex = -1;
b();希望对你有帮助 这个和你的情况差不多