我把数据库的值帮定在datagrid上了,里面用了模版列(textBox),(textBox)值修改后怎么保存到数据库中?我的连接数据库代码在类里面,不知道怎么保存请高手帮忙!
连接和帮定代码:
public class DataBase
{
private string strSQL;
//与SQL Server的连接字符串设置
private string connectionString = "server=(local);uid=sa;pwd=;database=Electricity";
//与数据库的连接
private SqlConnection myConnection;
private DataSet ds = new DataSet();//实例化
private SqlDataAdapter da;
public DataBase()
{
}
//** 描 述:连接操作数据库函数
//****************************************************************
public DataSet SelectDataBase(string tempStrSQL, string tempTableName)
{
{
this.strSQL = tempStrSQL;
this.myConnection = new SqlConnection(connectionString);
this.da = new SqlDataAdapter(this.strSQL, this.myConnection);
this.ds.Clear();
this.da.Fill(ds, tempTableName);
return ds;//返回填充了数据的DataSet,其中数据表以tempTableName给出的字符串命名
}
}在调用类的代码:
protected void database()
{
DataBase link = new DataBase();
this.ds = link.SelectDataBase(sendStrSQL, sendTableName);
}
绑定DataGrid1代码:
sendTableName="ClassScore1";
sendStrSQL="select * from ClassScore1";
database();
this.DataGrid1.DataKeyField = "ClassScoreId";
this.DataGrid1.DataSource=ds;
this.DataGrid1.DataBind();
急!!!!!!!!!!在线等!!
连接和帮定代码:
public class DataBase
{
private string strSQL;
//与SQL Server的连接字符串设置
private string connectionString = "server=(local);uid=sa;pwd=;database=Electricity";
//与数据库的连接
private SqlConnection myConnection;
private DataSet ds = new DataSet();//实例化
private SqlDataAdapter da;
public DataBase()
{
}
//** 描 述:连接操作数据库函数
//****************************************************************
public DataSet SelectDataBase(string tempStrSQL, string tempTableName)
{
{
this.strSQL = tempStrSQL;
this.myConnection = new SqlConnection(connectionString);
this.da = new SqlDataAdapter(this.strSQL, this.myConnection);
this.ds.Clear();
this.da.Fill(ds, tempTableName);
return ds;//返回填充了数据的DataSet,其中数据表以tempTableName给出的字符串命名
}
}在调用类的代码:
protected void database()
{
DataBase link = new DataBase();
this.ds = link.SelectDataBase(sendStrSQL, sendTableName);
}
绑定DataGrid1代码:
sendTableName="ClassScore1";
sendStrSQL="select * from ClassScore1";
database();
this.DataGrid1.DataKeyField = "ClassScoreId";
this.DataGrid1.DataSource=ds;
this.DataGrid1.DataBind();
急!!!!!!!!!!在线等!!
解决方案 »
- javascript中的List泛型集合
- 你永远都不应该使用嵌套式循环(循环里面套循环),你应该使用 Hash 表,数组或单一循环
- profile使用的问题
- 初学者 的问题~~~
- 关于object sender和 EventArgs e
- 如何使用ajaxpro.dll进行同步调用?
- 放了四个CrystalReportViewer在页面上,报表把页面撑的很大,什么原因
- 谁知道,怎么用asp.net调oracle 的package返回的cursor
- 在一个gridview中有一个按钮,点击它后先调用SqlDataSource的update方法,然后再获取当前行的id字段值跳转到其它页
- 请问怎样固定表格里 单元格的width?
- DropDownList1从数据库里面取出来的值,想在最前面加一个'请选择' 代码应该怎么改,谢谢.
- 服务器端控件和客户端控件的综合应用
LinkButton lbtn = (LinkButton) e.Item.FindControl("LbtnEdit");
Label lbl = (Label) (e.Item.FindControl("LblId"));
---
差不多就是上面的写法,改一下类型就可以了!
string str=txt.Text;
TextBox txt = (TextBox) e.Item.Cells[0].FindControl("txtBox1");
string str=txt.Text;