如何在asp.net中点击编辑按钮将gridview值绑定到文本框?

时间:2014-02-02 15:51:19

标签: asp.net

点击网格视图中的编辑按钮无法将模板字段中的标签值绑定到 行数据绑定事件中同一页面上的文本框

TxtVendor.Text = TryCast(e.Row.FindControl("lblGridvendname"), Label).Text

1 个答案:

答案 0 :(得分:0)

试试这个对我有用。

if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label lblVendor = (Label)e.Row.FindControl("lblGridvendname");
                TextBox txtVendor = new TextBox();
                txtVendor.Text = lblVendor.Text.ToString();
            }