FormView.FindControl(): object reference error

后端 未结 2 1959
没有蜡笔的小新
没有蜡笔的小新 2020-12-19 18:10

I have a formview that has several textboxes inside of tr/td\'s. I\'m trying to get the textboxes by using the .FindControl method but it\'s coming back null. The FormView

2条回答
  •  长情又很酷
    2020-12-19 18:51

    abatishchev's answer is right, although I found this variation a bit neater: it avoids having to call DataBind() explicitly.

    ...
    

    protected void DataBound(object sender, EventArgs e)
    {
        if (fvMember.CurrentMode == FormViewMode.Edit)
        {
            Label lblSubmit = fvMember.FindControl("lblSubmit") as Label;
            ...
        }
    }
    

提交回复
热议问题