Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Hi i have
VB
<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...............
Posted
Comments
Ahmed Bensaid 8-Feb-14 9:00am    
Firstly, the syntax inside the gridview should be <columns>.
Secondly, you could access the gridview just by calling his ID in code-behind ...
What do you have in your designer file ?

Syntax error : end tag is not matching

try this

XML
<asp:GridView ID="GridView1" runat="server">
            <Columns></Columns>
        </asp:GridView>


C#
GridView GridView1 = this.FindControl("GridView1") as GridView;
 
Share this answer
 
Comments
prabhatsp 11-Feb-14 5:16am    
thk u
Karthik_Mahalingam 11-Feb-14 5:31am    
Welcome prabhat:)
Just use its name directly:
GridView1.datasource=dt;
 
Share this answer
 
Comments
prabhatsp 8-Feb-14 12:31pm    
i dont want to use this method, i want to use only by findcontrol method

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900