本文介绍了请更正此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

异常详细信息:System.NullReferenceException:对象引用未设置为对象的实例.

源错误:


136行:
137行://currentTitleOfCourtesy =((TextBox)r.FindControl("TitleOfCourtesyTextBox")).Text;
第138行:currentLastName =((TextBox)r.FindControl("Name")).Text;
第139行:currentFirstName =((TextBox)r.FindControl("Location")).Text;
第140行://currentTitle =((TextBox)r.FindControl("TitleTextBox")).Text;


我在线路附近出现错误

currentLastName =(((TextBox)r.FindControl("Name")).Text;

感谢您的提前重播

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 136:
Line 137: //currentTitleOfCourtesy = ((TextBox)r.FindControl("TitleOfCourtesyTextBox")).Text;
Line 138: currentLastName = ((TextBox)r.FindControl("Name")).Text;
Line 139: currentFirstName = ((TextBox)r.FindControl("Location")).Text;
Line 140: //currentTitle = ((TextBox)r.FindControl("TitleTextBox")).Text;


I got Error Near The line

currentLastName = ((TextBox)r.FindControl("Name")).Text;

Thanks for your advance replay

推荐答案


int i = 0;
        foreach (GridViewRow row in GridView1.Rows)
        {
                ((TextBox)row.FindControl("TextBox1")).Text = "Hello";


            i++;
        }



这将完美地工作



This will work perfectly



这篇关于请更正此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 07:15