如何在asp.net中的代码中使用asp控件 [英] how to use the asp control in code behind in asp.net
本文介绍了如何在asp.net中的代码中使用asp控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好b $ b
你好我有
< asp:GridView ID = GridView1
runat = server>< column> < / 列 > < / GridView
如果我使用控制手段
GridView gd =(GridView)this.Page.FindControl(GridView1);
gd.datasource = dt;
显示错误对象引用未设置为对象的实例。
任何建议请...............
解决方案
语法错误:结束标记不匹配
试试这个
< asp:GridView ID = GridView1 runat = server >
< 列 > < /列 >
< / asp:GridView >
GridView GridView1 = 此 .FindControl( GridView1) as GridView;
直接使用它的名字:
GridView1.datasource = dt;
Hi
Hi i have
<asp:GridView ID="GridView1"
runat="server" ><column></column></GridView
If i use the control means
GridView gd = (GridView)this.Page.FindControl("GridView1");
gd.datasource=dt;
It shows the error "Object reference not set to an instance of an object."
Any suggestions please...............
解决方案
Syntax error : end tag is not matching
try this
<asp:GridView ID="GridView1" runat="server"> <Columns></Columns> </asp:GridView>
GridView GridView1 = this.FindControl("GridView1") as GridView;
Just use its name directly:
GridView1.datasource=dt;
这篇关于如何在asp.net中的代码中使用asp控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文