Wednesday, March 28, 2012

validating a gridview boundfield

i've been trying to follow along with a tutorial on how to create a custom BoundField that has built-in validation functionality. (tutorial is athttp://dotnet.sys-con.com/read/217541.htm.) being more than a little unfamiliar with how classes and assemblies work, i don't think i'm following him correctly, because i've been getting a couple errors that i haven't found how to solve.

in his example code page (athttp://res.sys-con.com/story/may06/217541/source.html) he has the full aspx page code at the bottom, but i'm not quite sure what to do with the c# code. would anyone be able to tell me where to put these code pieces? i've tried putting them in the code-behind page as well as a new file under app_code, but i get the build error "unknown server tag 'Powered01Cs:PoweredBoundField'." i also have no idea what "InitializeCell" is supposed to be overriding.

the author says the full demo is available for download, but i can'tfind the download link. if anyone sees where it is, i would dearlylove to know.

thanks so much for any pointers.would anyone know of any other tutorials perhaps?

bttrflii:


..as well as a new file under app_code, but i get the build error "unknown server tag 'Powered01Cs:PoweredBoundField'."

You need to make the application aware of the namespace. In web.config:
<system.web>
...
<pages>
<controls>
<addtagPrefix="Powered01Cs"namespace="Powered01Cs" />
</controls>
</pages>
</system.web>

bttrflii:


i also have no idea what "InitializeCell" is supposed to be overriding.

From the help:

TheInitializeCell method is implemented byBoundField-derived types to add text and controls to aTableCell object of a data control that uses tables to display a user interface (UI). These data controls create the complete table structure row-by-row when the control'sCreateChildControls method is called. TheInitializeCell method is called by theInitializeRow method of data controls such asDetailsView andGridView.

Call this method when you are writing a custom data-bound control that usesTableCell objects to initialize the cells of the table structure with data or controls. Implement this method when you are writing aBoundField-derived class.

Hope this gets you a bit further.


thanks a bunch sjonnie! it seems that every time i think i'm taking a step forward, i take a dozen leaps back. now that i'm past *that* error, it appears that the code given in his "listings" isn't even all the code needed to get his example to work. being the complete dunce i am, i might have to just find that magazine's contact info and ask for the complete and working example after all. i feel like i'm trying to complete a complex puzzle armed with the knowledge that half the pieces are missing...

i sincerely appreciate the pointers. :) thank you!

No comments:

Post a Comment