GridView中采用来LinkButton修改表格中的数据(绑定数据在TextBox中)
2013-10-22 08:57
316 查看
【实例1】直接在数据库中读取
protected void alter_Click(object sender, EventArgs e)//修改
{
Panel1.Visible = true;
LinkButton lbt = (LinkButton)sender;
DataControlFieldCell dcf = (DataControlFieldCell)lbt.Parent;
GridViewRow gvr = (GridViewRow)dcf.Parent;
//选中行标注颜色
foreach (GridViewRow gvr1 in GV_PF.Rows)
{
gvr1.BackColor = System.Drawing.Color.Empty;//没有颜色,透明
}
gvr.BackColor = (System.Drawing.Color)(new System.Drawing.ColorConverter()).ConvertFromString("#669999");
decimal id = Convert.ToDecimal(gvr.Cells[10].Text.Trim());
id_main = id;
private BLL.OriginalCertificate.AlterOriginalCertificate B_AlterOriginalCertificate = new BLL.OriginalCertificate.AlterOriginalCertificate();
Entity.TB_OriginalCertificate E_TB_OriginalCertificate = B_AlterOriginalCertificate.getEntity(id_main);// 得到一个对象实体(model层)
txt_Explain.Text = E_TB_OriginalCertificate.Explain;
txt_Bills.Text = E_TB_OriginalCertificate.Bills.ToString();
txt_TotalMoney.Text = E_TB_OriginalCertificate.TotalMoney.ToString();
txt_Idea.Text = " 验收人:" + E_TB_OriginalCertificate.Idea_Test
+ "\n\r 主席:" + E_TB_OriginalCertificate.Idea_Chairman;
*****************************************************************************************
【实例2】直接在GridView中读取
protected void lbnAlertClick(object sender, EventArgs e) //修改记录
{
GridViewRow gvr = (GridViewRow)((DataControlFieldCell)(((LinkButton)(sender)).Parent)).Parent;
//选中行标注颜色
foreach (GridViewRow gvr1 in gvList.Rows)
{
gvr1.BackColor = System.Drawing.Color.Empty;//没有颜色,透明
}
gvr.BackColor = (System.Drawing.Color)(new System.Drawing.ColorConverter()).ConvertFromString("#9900FF");
绑定数据在TextBox中
txtName_File.Text = gvr.Cells[2].Text;
txtSummary.Text = gvr.Cells[3].Text;
txtRemark.Text = gvr.Cells[4].Text;
ViewState["index"] = gvr.Cells[0].Text;
ViewState["Id"] = gvr.Cells[1].Text; //ID
trAlert.Style.Value = "";
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
添加【修改】按钮
protected void btnAlert _Click(object sender, EventArgs e) //修改按钮操作
{
if (txtName_File.Text.Trim() != "" &&txtSummary.Text.Trim() != "")
{
Entity.TB_ProductionPlan E_ProductionPlan = new Entity.TB_ProductionPlan();
E_ProductionPlan.Id = Convert.ToDecimal(ViewState["Id"].ToString());
E_ProductionPlan.Name_File = txtName_File.Text.Trim();
E_ProductionPlan.Summary = txtSummary.Text.Trim();
E_ProductionPlan.Id_ReportPerson = Convert.ToDecimal(Session["USER_ID"]);
E_ProductionPlan.Date_Report = DateTime.Now;
if (B_ProductionPlanAlert.update(E_ProductionPlan)) //更新一条记录
{
msgBox.Show(this, "修改成功!");
}
}
}
protected void alter_Click(object sender, EventArgs e)//修改
{
Panel1.Visible = true;
LinkButton lbt = (LinkButton)sender;
DataControlFieldCell dcf = (DataControlFieldCell)lbt.Parent;
GridViewRow gvr = (GridViewRow)dcf.Parent;
//选中行标注颜色
foreach (GridViewRow gvr1 in GV_PF.Rows)
{
gvr1.BackColor = System.Drawing.Color.Empty;//没有颜色,透明
}
gvr.BackColor = (System.Drawing.Color)(new System.Drawing.ColorConverter()).ConvertFromString("#669999");
decimal id = Convert.ToDecimal(gvr.Cells[10].Text.Trim());
id_main = id;
private BLL.OriginalCertificate.AlterOriginalCertificate B_AlterOriginalCertificate = new BLL.OriginalCertificate.AlterOriginalCertificate();
Entity.TB_OriginalCertificate E_TB_OriginalCertificate = B_AlterOriginalCertificate.getEntity(id_main);// 得到一个对象实体(model层)
txt_Explain.Text = E_TB_OriginalCertificate.Explain;
txt_Bills.Text = E_TB_OriginalCertificate.Bills.ToString();
txt_TotalMoney.Text = E_TB_OriginalCertificate.TotalMoney.ToString();
txt_Idea.Text = " 验收人:" + E_TB_OriginalCertificate.Idea_Test
+ "\n\r 主席:" + E_TB_OriginalCertificate.Idea_Chairman;
*****************************************************************************************
【实例2】直接在GridView中读取
protected void lbnAlertClick(object sender, EventArgs e) //修改记录
{
GridViewRow gvr = (GridViewRow)((DataControlFieldCell)(((LinkButton)(sender)).Parent)).Parent;
//选中行标注颜色
foreach (GridViewRow gvr1 in gvList.Rows)
{
gvr1.BackColor = System.Drawing.Color.Empty;//没有颜色,透明
}
gvr.BackColor = (System.Drawing.Color)(new System.Drawing.ColorConverter()).ConvertFromString("#9900FF");
绑定数据在TextBox中
txtName_File.Text = gvr.Cells[2].Text;
txtSummary.Text = gvr.Cells[3].Text;
txtRemark.Text = gvr.Cells[4].Text;
ViewState["index"] = gvr.Cells[0].Text;
ViewState["Id"] = gvr.Cells[1].Text; //ID
trAlert.Style.Value = "";
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
添加【修改】按钮
protected void btnAlert _Click(object sender, EventArgs e) //修改按钮操作
{
if (txtName_File.Text.Trim() != "" &&txtSummary.Text.Trim() != "")
{
Entity.TB_ProductionPlan E_ProductionPlan = new Entity.TB_ProductionPlan();
E_ProductionPlan.Id = Convert.ToDecimal(ViewState["Id"].ToString());
E_ProductionPlan.Name_File = txtName_File.Text.Trim();
E_ProductionPlan.Summary = txtSummary.Text.Trim();
E_ProductionPlan.Id_ReportPerson = Convert.ToDecimal(Session["USER_ID"]);
E_ProductionPlan.Date_Report = DateTime.Now;
if (B_ProductionPlanAlert.update(E_ProductionPlan)) //更新一条记录
{
msgBox.Show(this, "修改成功!");
}
}
}
相关文章推荐
- Java中instanceof关键字的用法总结
- Android利用Fiddler进行网络数据抓包
- Java Project和Web Project 区别
- 情感分析资源 (转)
- windows下mysql数据库安装(每一步都有截图和说明)
- windows、linux文件转换
- 委托 你怎么看?
- 拓展,三个数比较大小
- //手机网页监控所有对象按下的样式
- 表达式语言的内置对象
- 一句话 手机页中按钮去点击背景
- OCP-1Z0-051-V9.02-8题
- 采集Snoopy.class.php
- 看山不是山,看水不是水
- 进程与线程的区别和联系
- SpringMVC 利用AbstractRoutingDataSource实现动态数据源切换
- 脂肪肝
- Linux系统管理命令
- eclipse中配置SVN
- ndk开发总结