Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)归海一刀
published in(发表于) 2014/1/30 1:21:34
asp.net得到GridView中自定义控件的值_[Asp.Net教程]

asp.net得到GridView中自定义控件的值_[Asp.Net教程]
如何获得MAmount的值


’ />


问题补充:要将GridView中的数据批量修改,用FindControl获得’ />的值
cmd.CommandType = CommandType.Text;
cmd.CommandText = "update yf_Purchases set Main=@Main, MAmount=@MAmount,MOverDate=@MOverDate,MMPrice=@MMPrice where OrderID=@OrderID";
cmd.Parameters.Add("@OrderId", SqlDbType.NVarChar, 20);
cmd.Parameters.Add("@Main", SqlDbType.NVarChar, 10);
cmd.Parameters.Add("@MAmount", SqlDbType.Int);
cmd.Parameters.Add("@MOverDate", SqlDbType.VarChar,50);
cmd.Parameters.Add("@MMPrice", SqlDbType.Int);
cmd.Parameters["@OrderId"].Value = ((HiddenField)gvr.FindControl("OrderID")).Value;
cmd.Parameters["@Main"].Value = ((TextBox)gvr.FindControl("Main")).Text;
cmd.Parameters["@MAmount"].Value =?
答:
例子:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.Cells[12].Text.ToString() == "提交待审核" || e.Row.Cells[12].Text.ToString() == "审核通过")
{
Label lbl_edit = e.Row.FindControl("Label1_edit") as Label;
Label lbl_editr = e.Row.FindControl("Label1_editr") as Label;
lbl_edit.Visible = false;
lbl_editr.Text = " ";
lbl_editr.Visible = true;
}
}
catch { }
}


If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759