This is a migrated thread and some comments may be shown as answers.

Loop through grid results and fire off event based on results

1 Answer 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Big
Top achievements
Rank 1
Big asked on 05 Jun 2012, 06:42 PM
I have a Data Grid that currently displays information.   

I have a column named "Status" that displays P, C, or I

I have a Rebind occurring every 15 seconds

After each rebind, or during (not sure) I want to check each row for
the value "P".  If that column Status is P, i want to count it and add it
to a variable.

Once the count is complete after the grid loads, I want to fire off some
script based on the results.

So if there are any values of P in the grid results, I want do something.

How can I accomplish this?   Below is what I started to do, but its not
working right.

Again, trying to loop through EVERY ROW, get the calculated value based
on what the Status is.  If there are no statuses processing, then I will
return a 0 and do something.

What's the best way of doing this?



protected void grdData_ItemDataBound(object sender, GridItemEventArgs e)
      {
 
           for (int i = 0; i < grdData.MasterTableView.Items.Count; i++)
          {
         
              string status = item["Status"].Text;
             
             
      
              if (status == Constants.RunStatusCodes.PROCESSING)
                 {
                  processingModels = processingModels + 1;
                 }
                   
              
          }
 
 
          if (processingModels == 0)
          {
              txtActive.Text = "N";
              updPanel.Update();
          }

1 Answer, 1 is accepted

Sort by
0
Big
Top achievements
Rank 1
answered on 05 Jun 2012, 08:37 PM
this did the trick :)

foreach (GridDataItem items in grdData.Items)
        {
            if (items["Status"].Text == Constants.RunStatusCodes.PROCESSING)
           {
               processingModels = processingModels + 1;
           }
            
        }
Tags
Grid
Asked by
Big
Top achievements
Rank 1
Answers by
Big
Top achievements
Rank 1
Share this question
or