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

[Solved] ItemDataBound and paging

2 Answers 200 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex White
Top achievements
Rank 1
Alex White asked on 08 Jul 2009, 11:43 AM

 

 

Hi,

I am working on a RadGrid that has worked perfectly up till now, I use the event below to translate the true/false returned from the database into yes/no, I have other situtions where the translation maybe more complex e.g. a specific string to another string like 'yes' = 'this item has been delivered!'

where my problem is, is that I have introduced grid paging, now the first page is formatted correctly and all subsequent pages dont have the translations in them.

void
grdDelivery_ItemDataBound(object sender, GridItemEventArgs e) {

 

 

 

    if (e.Item is GridDataItem) {

 

 

 

        GridDataItem databounditem = e.Item as GridDataItem;

 

 

 

        if (bool.Parse(databounditem["deliveryclosed"].Text) == false) {

 

            databounditem[

 

"deliveryclosed"].Text = "No";

 

        }

 

else {

 

            databounditem[

 

"deliveryclosed"].Text = "Yes";

 

        }

    }

}

any help would be great.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 09 Jul 2009, 05:28 AM
Hi Alex,

I tried the above given code on my end and is working fine with paging. Can you try a similar approach in the PreRender event of the Grid and see whether it is working.

CS:
 
 
  
 protected void grdDelivery_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridDataItem item in grdDelivery.MasterTableView.Items)  
        {   
          if(bool.Parse(item["deliveryclosed"].Text)==false)  
             item["deliveryclosed"].Text = "No";  
            else  
              item["deliveryclosed"].Text = "Yes";  
        }  
    }  


Regards
Shinu
0
Alex White
Top achievements
Rank 1
answered on 10 Jul 2009, 01:29 PM
hi,

that worked perfectly


thank you.
Tags
Grid
Asked by
Alex White
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Alex White
Top achievements
Rank 1
Share this question
or