Lessons, tips, and experiences from venturing through the realms of technology and software.

Sunday, June 7, 2009

How to Pass Record Value into Function from GridView or DataView (ASP.NET)

In order to pass a database record value into a custom function of your own from a GridView or DataView in ASP.NET, you will find that you cannot just simply pass the table field's name like it is done with Bind (eg, <%# Bind("fieldname") %>) ).

However, the following code will allow one to successfully pass the record value:


<%# yourFunction( (int) Eval("fieldname") ) %>

Alternatively, one can replace the (int) to (string) or whatnot in order to cast the value to the desired type.


No comments:

This site is a Coconuter production