Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BoundColumn conditions

Status
Not open for further replies.

chromarog

MIS
Mar 15, 2001
61
US
I need to have a seperate column that displays a warning if the condition is met. I'm trying to find examples of if then statements but I can't find anything out there or I'm looking for the wrong thing. I'm looking to add a fourth column that will have a flag, text, picture, anything, that will throw up a warning that if the column 2 equals or exceeds column 3 then the fourth column or flag column, lets the user know.

Here's the code.
ASP Side:

<asp:DataGrid ID="GridView1" runat="server" autogeneratecolumns="false">
<HeaderStyle Font-Bold="true" />
<Columns>
<asp:BoundColumn HeaderText="Part Number" DataField="partnumber" />
<asp:BoundColumn HeaderText="Actual" datafield="actual"/>
<asp:BoundColumn HeaderText="OrderPoint" DataField="orderpoint" />
</Columns>
</asp:DataGrid>


VB Side:

Dim MYSQL3 As String

MYSQL3 = " select partnumber, (sum(scanqty)-sum(orderqty)) as actual, "
MYSQL3 += " (select orderpoint "
MYSQL3 += " from KanBan.dbo.KBTEST "
MYSQL3 += " where tblVSKB_activitylog.partnumber = kbtest.partnumber) as orderpoint "
MYSQL3 += " FROM [Kanban].[dbo].[tblVSKB_ActivityLog] "
MYSQL3 += " group by partnumber "
MYSQL3 += " order by actual desc "

Dim MyDataAdapter = New SqlDataAdapter(MYSQL3, KBCS)
Dim MyDataSet As New Data.DataSet
MyDataAdapter.Fill(MyDataSet, "MYSQL3")
GridView1.DataSource = MyDataSet.Tables("MYSQL3").DefaultView
GridView1.DataBind()
MyDataAdapter.Dispose()


Any insight to fixing this or even where to look for a different approach would be fine. I have looked into using a stored proc for this to make it cleaner but I still need the extra column issue worked out.

Thanks,
Rog...
 
First I would use a stored procedure as you already have mentioned. Second, there are 2 ways to go about it, you can calculate what you need in the itemdatabound event or, do it in SQL. For simplicity, maintenance and performance sake, I would do the calculation in SQL. In your SQL, you can have a 4th calculated column of any type. I would create a bit column and set it to true if your condition is met. Then, on the front end, in the itemdatabound event of the grid, you can check that boolean value. If it is true, display text, an image or whatever you want, else, display nothing.
 
Wow, that seems easy enough. I was making this waaaay to hard.

Thanks again,
Rog...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top