[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

DataGrid OnItemDataBound Event

Posted on 2004-10-29
4
Medium Priority
?
1,464 Views
Last Modified: 2008-02-07
I have a data grid control that lists a bunch of aggregate data against a list of entities.  In a case where the entity has 0 in each column i need to remove that row from the grid so it isn't shown.

I understand the datagrid control is only visible from the client side but any documentation I have about the onDataBind event details writing this code to the server side.  So this has confused me considerably.

How can I achieve this?

To test an idea I tried this in the HTML (and wrote a little function called removezerorows) but I get a compile error.
<asp:datagrid id="grdBudget" OnItemDataBound="RemoveZeroRows();"

function RemoveZeroRows()
{
      alert('Removing Zero Row');
}
0
Comment
Question by:billy21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Author Comment

by:billy21
ID: 12442752
I also need to know how to remove the row and how I can access the item that is being databound.
0
 
LVL 18

Expert Comment

by:tusharashah
ID: 12443428
You can Access those rows like folling in your ItemDataBound event..

----------------------------------------------------------------------------------------------------------------
//In Following code I'm hiding rows for wich TotalSales is less then 100....

private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
      switch( e.Item.ItemType )
      {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:

            double TotalSales = Convert.ToDouble( e.Item.Cells[7].Text );  //TotalSales
                       if ( TotalSales < 100 ) e.Item.Visible = false;

            break;
      }
}
----------------------------------------------------------------------------------------------------------------

-tushar
0
 
LVL 6

Author Comment

by:billy21
ID: 12443692
Sorry but need it in VB and need to actually remove the rows.
0
 
LVL 18

Accepted Solution

by:
tusharashah earned 2000 total points
ID: 12443709
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
 Select e.Item.ItemType
 Case ListItemType.Item, ListItemType.AlternatingItem
   Dim TotalSales As Double = Convert.ToDouble(e.Item.Cells(7).Text)
   If TotalSales < 100 Then
     e.Item.Visible = False
   End If
   ' break
 End Select
End Sub
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question