[英]Change label text from the button outside GridView asp.net c#
下面的代碼僅適用於GridViewCommandEventArgs
但這次我想在單擊按鈕時使用這種方法。 我如何修改此代碼以便將其用於按鈕單擊。 即時通訊正在研究使用gridview外部的按鈕更改文本。
GridViewRow row = (GridViewRow)((Button)e.CommandSource).NamingContainer;
Label label = row.FindControl("lbl_reviewDate") as Label;
label.Text = DateTime.Now.Date.ToString("d");
Label labelID = row.FindControl("lbl_id") as Label;
我希望這有幫助:
protected void btn_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in YourGridviewName.Rows)
{
Label label = row.FindControl("lbl_reviewDate") as Label;
label.Text = DateTime.Now.Date.ToString("d");
Label labelID = row.FindControl("lbl_id") as Label;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.