Groups | Blog | Home
all groups > asp.net webcontrols > october 2007 >

asp.net webcontrols : Dynamic calculations in a GridView


C
10/3/2007 3:28:01 AM
Hi,

I am posting this on the aspnet.webcontrols board as someone may have done
something similar.

I have a series of Database tables which hold various fields and details of
how they are calculated.

I take these details and bind them to a Gridview with a Description of each
item and a textbox so the user can input some integer value.

On the server side in my C# code I do some calculations dynamically.

I want to do these dynamically also on the client side in JavaScript. My
questions are as follows:
1 To do this I need to push out my database details of how the fields are
calculated on the client. I get back a collection of ojects in my c# code
where each object has an id and details of the calculation for each field.
How can I stored this on the form so I can get a handle on it in my
JavaScript?
2 I need to be able to get the id from my GridView so I can do my
calculations. I have this in my GridView but I don't want to display this on
the UI so I have set the BoundColumn to be not visible. As a result it does
not get rendered so I cannot get a handle on it.

Any advice on above would be greatly appreciated.

Thanks in Advance,
C.
David R. Longnecker
10/4/2007 2:56:44 PM
If you need to "hide" columns, yet still access them programatically using
either C# or JavaScript, you can use CSS.

<style type="text/css">
.HiddenColumn { display: none; }
</style>

Then, down on the column you want to "hide":

<asp:boundfield DataField="UnitPrice" HeaderText="UnitPrice"
ItemStyle-CssClass="HiddenColumn"
HeaderStyle-CssClass="HiddenColumn" />

But, you can still access it in code behind without any issues.

-dl

--
David R. Longnecker
http://blog.tiredstudent.com

[quoted text, click to view]

AddThis Social Bookmark Button