User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,504 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,665 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2440 | Replies: 3
Reply
Join Date: Sep 2006
Location: Indiana USA
Posts: 12
Reputation: kingflux is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kingflux's Avatar
kingflux kingflux is offline Offline
Newbie Poster

Question How to hide datagrid rows where Qty is blank?

  #1  
Sep 26th, 2007
Hello-- I have an ordering screen that displays hundreds of items in a datagrid and provides a blank for the user to enter a Quantity. Datagrid "CatalogGrid" is bound to a datasource which is based on the System.Collection.CollectionBase class. If the user has entered a Quantity on a row, the quantity is displayed on the same datagrid row via a datasource which is based on the System.Collections.DictionaryBase class. (See code snippets below.)

My goal is to create a new Order Preview page that shows only ordered items, allowing the user to change the quantity or delete. In that situation, ss there a way to hide rows where the Quantity is blank, while still using this datasource implementation? See mock-up image here: http://www.enardoni.com/download/ord...iew_mockup.gif

Thank you in advance for your consideration!

===
ASP.NET with Visual Basic, using Visual Studio 2003. I'm a relatively new developer who inherited the source code from an expert programmer, so please bear with me!

From the ASPX page:

<asp:BoundColumn DataField="ItemNumber" HeaderText="Item #">
    <HeaderStyle Width="3%"></HeaderStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Qty">
    <HeaderStyle Width="5%"></HeaderStyle>
    <ItemTemplate>
        <asp:TextBox id="QuantityTextbox" runat="server" Text='<%# DataGrid_BindQuantity(DataBinder.Eval(Container, "DataItem.ItemId")) %>'  </asp:TextBox>
    </ItemTemplate>
</asp:TemplateColumn>

From the code-behind:
    CatalogGrid.DataSource = CatalogItems.PageFill
    CatalogGrid.DataBind()
        Protected Function DataGrid_BindQuantity(ByVal dataItem As Object) As String
            Dim value As String = String.Empty

            Dim ThisOrder As MyOrderClass = CType(Me.GetSessionValue("Order"), MyOrderClass)
            If Not IsNothing(ThisOrder) Then
                Dim ItemId As String = dataItem.ToString
                If ThisOrder.OrderedItems.Contains(ItemId) Then
                    value = ThisOrder.OrderedItems(ItemId).Quantity.ToString()
                End If
            End If

            Return value
        End Function
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: England
Posts: 156
Reputation: ptaylor965 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: How to hide datagrid rows where Qty is blank?

  #2  
Sep 26th, 2007
Try
If datagrid.rows.count = 0 then
datagrid.visible = False
else
datagrid.visible = True
End If
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote  
Join Date: Sep 2006
Location: Indiana USA
Posts: 12
Reputation: kingflux is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kingflux's Avatar
kingflux kingflux is offline Offline
Newbie Poster

Re: How to hide datagrid rows where Qty is blank?

  #3  
Sep 26th, 2007
Thank you for writing, Peter. Your suggested code appears to hide the entire datagrid; in this case, I just need to hide the rows of the datagrid that do not have a Quantity entered.

What do you think?
Reply With Quote  
Join Date: Oct 2006
Location: England
Posts: 156
Reputation: ptaylor965 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: How to hide datagrid rows where Qty is blank?

  #4  
Sep 26th, 2007
I would normally use this with a dataview in Windows Applications but the concept should be the same
Dim SQLRow as datarow
Dim Index as Integer = 0

For Each SQLRow In DataGrid.Rows
If SQLRow(ColumnName).tostring = "" Then
DataGrid.Rows(Index).Visible = False
else
DataGrid.Rows(Index).Visible = True
End If

Index += 1
Next
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 3:35 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC