如何使用asp.net中gridview外部的更新按钮更新gridview中的行 [英] How can i update the row in the gridview by using update button which is in outside of the gridview in asp.net

查看:109
本文介绍了如何使用asp.net中gridview外部的更新按钮更新gridview中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我修改了应该通过点击外部按钮更新的特殊行的值时,我在表单中有一个gridview。

请帮助我。

I have a gridview in the form when i modified the values of purticular row that should be updated by clicking of outside button.
Please help me.

推荐答案

for (int i = 0; i < Grid_More.Rows.Count; i++)
                  {
  obj.BHID =((TextBox)Grid_More.Rows[i].FindControl("txt_Bhid")).Text);
                     obj.mFrom=Convert.ToDecimal(((TextBox)Grid_More.Rows[i].FindControl("txt_Mfrom")).
Text.Trim());
obj.mTO = Convert.ToDecimal(((TextBox)Grid_More.Rows[i].FindControl("txt_MTo"))
.Text.Trim());





//在此使用您的更新流程

}



//use your update process here
}


查看以下链接: -



在gridview外面点击按钮的所有gridview行 [ ^ ]
check below link:-

edit all rows of gridview on button click which is outside gridview[^]


protected void gridview1_RowEditing(object sender, GridViewEditEventArgs e)
{
    gridview1.EditIndex = e.NewEditIndex;
    BindGrid();
}

protected void gridview1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
    gridview1.EditIndex = -1;
    BindGrid();
}













protected void gridview1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    GridViewRow row = gridview1.Rows[e.RowIndex];
    int id = Convert.ToInt32(gridview1.DataKeys[e.RowIndex].Value);
    string name = ((DropDownList)(row.Cells[2].Controls[1])).SelectedValue;

    //call save method of your business layer

    gridview1.EditIndex = -1;
    BindGrid();
}


这篇关于如何使用asp.net中gridview外部的更新按钮更新gridview中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆