C#.net中如何保存带模版列(textBox)的数据
我把数据库的值帮定在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();
急!!!!!!!!!!在线等!!
------解决方案--------------------http://adandelion.cnblogs.com/archive/2005/11/12/274505.html
Label lblName = (Label) e.Item.FindControl( "LblName ");
LinkButton lbtn = (LinkButton) e.Item.FindControl( "LbtnEdit ");
Label lbl = (Label) (e.Item.FindControl( "LblId "));
---
差不多就是上面的写法,改一下类型就可以了!