pro小白 2015-05-03 06:44 采纳率: 50%
浏览 741

gridview点击更新后数据都给清空了 为什么啊

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string listnumber = GridView1.Rows[e.RowIndex].Cells[0].Text;
string cnumber = GridView1.Rows[e.RowIndex].Cells[1].Text;
string cknumber = GridView1.Rows[e.RowIndex].Cells[2].Text;
string lname = GridView1.Rows[e.RowIndex].Cells[3].Text;
string lphonne = GridView1.Rows[e.RowIndex].Cells[4].Text;
string ladd = GridView1.Rows[e.RowIndex].Cells[5].Text;
// DateTime ldate = DateTime.ParseExact(GridView1.Rows[e.RowIndex].Cells[6].Text, "yyyy-MM-dd HH:mm:ss", null);
string ltime = GridView1.Rows[e.RowIndex].Cells[7].Text;
string lcandle = GridView1.Rows[e.RowIndex].Cells[8].Text;
string lclaim = GridView1.Rows[e.RowIndex].Cells[9].Text;
//double lckprice = double.Parse(GridView1.Rows[e.RowIndex].Cells[10].Text);
string linputdate = GridView1.Rows[e.RowIndex].Cells[11].Text;
string luser = GridView1.Rows[e.RowIndex].Cells[12].Text;

         //dispatchinfo dis = new dispatchinfo();
         var q = from t1 in ctx.dispatchinfo
                 where t1.listnumber == listnumber && t1.cnumber==cnumber && t1.cknumber==cknumber
                 select t1;
        // var target = q.FirstOrDefault<dispatchinfo>();

         foreach (var item in q)
         {
             item.lname = lname;
             item.lphonne = lphonne;
             item.ladd = ladd;
            // item.ldate = ldate;
             item.ltime = ltime;
             item.lcandle = lcandle;
             item.lclaim = lclaim;
             //item.lckprice = lckprice;

         }

         ctx.SaveChanges();
          BindDataSource();
        // GridView1.DataBind();
    }

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
    • ¥15 C# datagridview 单元格显示进度及值
    • ¥15 thinkphp6配合social login单点登录问题
    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配