日期:2014-05-17 浏览次数:20439 次
public class GVType { public int CartID { get; set; } public int MemberID { get; set; } public int GoodID { get; set; } public string Name { get; set; } public decimal MemberPrice { get; set; } public int Count { get; set; } public decimal Total { get; set; } public string Unit { get; set; } public string SettleWay { get; set; } public DateTime AddTime { get; set; } public string Unit_Show { get; set; } }
private static List<GVType> SCart; static public IEnumerable<GVType> GetDataSourse(int memberID) { if (SCart == null) { //从数据库中得到DataSet并填充到SCart去 } return SCart; }
GridView1.DataSource = BLL_GridView.GetDataSourse(1000);
public class GVType { public int CartID { get; set; } public int MemberID { get; set; } public int GoodID { get; set; } public string Name { get; set; } public decimal MemberPrice { get; set; } public int Count { get; set; } public decimal Total { get; set; } public string Unit { get; set; } public string SettleWay { get; set; } public DateTime AddTime { get; set; } public string Unit_Show { get; set; } public int IsDel {get;set;} }
------解决方案--------------------
一般用 断开式连接就可以搞定了吧!
以下是代码段。
private DataSet dataSet = new DataSet();
private SqlDataAdapter dataAdapter;
private SqlConnection conn;
//构造方法里 获取 conn连接
.........
//加载事件
private void Form1_Load(object sender, EventArgs e)
{
try
{
//查询SQL语句
string sql = "select * form 表1";
//初始化DataAdapter
dataAdapter = new SqlDataAdapter(sql, conn);
//填充DataSet
dataAdapter.Fill(dataSet, "表1");
//指定DataGridView的数据源
DgvTeacher.DataSource = dataSet.Tables["表1"];
}
catch (Exception ex)
{
MessageBox.Show("查找数据时出错", "错误提示");
}
}
//保存按钮事件
private void button1_C