For Programmers: Free Programming Magazines  


Home > Archive > C# > April 2006 > Inserting using Custom Control Inherited From GridView









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Inserting using Custom Control Inherited From GridView
Powerboy

2006-04-27, 4:02 am

I've recently started using the GridView control in my ASP .NET 2.0 web
based applications, when I came across the problem of inserting new records.

I started off using GridView's FooterTemplate by following Fredrik Normén's
blog entry:
http://fredrik.nsquared2.com/viewpost.aspx?PostID=155

This partly solved my problem; the next issue was how to insert when no data
exists. I stumbled upon this blog entry by Kevin Marshall which got me part
of the way there:
http://blogs.claritycon.com/blogs/k...ve/2006/02.aspx

The problem now is that when I attempt to access one of the controls in the
FooterTemplate, and no data exists in the view, inserting a record generates
an "Object reference not set to an instance of an object" error for the
following line of code:

TextBox someTextBox = MyGridView.FooterRow.FindControl("SomeTextBox") as
TextBox;
(The textbox does exist as part of the FooterTemplate of MyGridView).

I'm not sure how to add the controls defined in the EmptyGridView's
FooterTemplate in the CreateChildControls method.

Any help would be greatly appreciated.

TIA


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com