[thelist] ASP.NET: Logic on a DataGrid?

Casey Crookston caseyc at IntelliSoftmn.com
Fri Aug 18 14:36:48 CDT 2006

I'm pulling data from a database table and binding it to a datagrid. I
need to perform some logic on one of the 4 columns being queried. Here's
a simple example of what I need (showing only the logic... I know syntax
is not correct):

cmd = "SELECT columnA, columnB, columnC, columnD FROM table"
dataGrid.DataSource = cmd

<asp:image id=" MyImg" runat="server"/>

<%# Container.DataItem("columnB") %>
<%# Container.DataItem("columnC") %>
<%# Container.DataItem("columnD") %>

MyImg is based on columnA, which is an integer. I need to do some math
based on other criteria and then set the image URL accordingly:


Dim MyInt as integer = (columnA* another variable)/100 

If MyInt > x then MyImg.ImageURL = optionA

Else MyImg.ImageURL = optionB


Is a datagrid the best tool to use based on these needs? If not, what
data display took should I be using? I'd rather not put the data into a
datareader and then parse through it all one item at a time, but I can
if that's my only option.

Thanks! Casey

More information about the thelist mailing list