Cell value set to "" return  

4 posts, 0 answers
  1. Filleau
    Filleau avatar
    114 posts
    Member since:
    Jun 2006

    Posted 16 Sep 2008 Link to this post

    Hi

    I have a little problem with empty cells.
    If I set a cell to ""  the cell return &nbsp
    I understand this.

    I would like to know if there is a way that cell.text return nothing.

    Actualy I have to put a lot of if in order to have the good result.

    For

    Each item As GridDataItem In Grille.Items 
      
    If item.Selected Then 
        
    If item("Tel.").Text <> "&nbsp;" Then ZTel.Text = item("Tel.").Text Else ZTel.Text = "" 
        If item("Nom").Text <> "&nbsp;" Then ZNom.Text = item("Nom").Text Else ZNom.Text = "" 
        
    If item("Soc").Text <> "&nbsp;" Then ZSoc.Text = item("Soc").Text Else ZSoc.Text = "" 
        
    If item("Lieu").Text <> "&nbsp;" Then Zlocal.Text = item("Lieu").Text Else Zlocal.Text = "" 
        
    If item("Prenom").Text <> "&nbsp;" Then ZPrenom.Text = item("Prenom").Text Else ZPrenom.Text = "" 
        
    If item("Gsm").Text <> "&nbsp;" Then Zgsm.Text = item("Gsm").Text Else Zgsm.Text = "" 
        If item("Servic").Text <> "&nbsp;" Then Zservice.Text = item("Servic").Text Else Zservice.Text = "" 
        
    If item("email").Text <> "&nbsp;" Then Zemail.Text = item("email").Text Else Zemail.Text = "" 
        
    If item("titre").Text <> "&nbsp;" Then Ztitre.Text = item("titre").Text Else Ztitre.Text = "" 
        
    If item("Sam").Text <> "&nbsp;" Then ZSamSec.Text = item("Sam").Text Else ZSamSec.Text = "" 
        
    If item("Sec").Text <> "&nbsp;" Then Zsec.Text = item("Sec").Text Else Zsec.Text = "" 
        
    If item("Telsec").Text <> "&nbsp;" Then Zsectel.Text = item("Telsec").Text Else Zsectel.Text = "" 
        Exit For
      End If
    Next


    Is there a best way ???

    Thanks all
  2. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 16 Sep 2008 Link to this post

    Hello Filleau,

    I suppose this approach may give you some ideas:

    C#:
    foreach (GridDataItem item in RadGrid1.MasterTableView.GetSelectedItems()) 
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
            (FindControl("Z" + col.UniqueName) as TextBox).Text = (item[col.UniqueName].Text != "&nbsp;") ? item[col.UniqueName].Text : null
     

    VB:
     For Each item As GridDataItem In RadGrid1.MasterTableView.GetSelectedItems() 
         For Each col As GridColumn In RadGrid1.MasterTableView.RenderColumns 
             TryCast(FindControl("Z" + col.UniqueName), TextBox).Text = IIf((item(col.UniqueName).Text <> "&nbsp;"),item(col.UniqueName).Text,Nothing
         Next 
     Next 

    Regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Filleau
    Filleau avatar
    114 posts
    Member since:
    Jun 2006

    Posted 17 Sep 2008 Link to this post

    Thanks Daniel

    Your approach is very good, but I'm affraid it will more optimize the number of line code than the application speed.

    What I'm looking for is to improve performance.

    So what il would like to do will be to delete all the tests (if) but I don't want to see "nbsp," in my text box  if my cell grid is équal to Nothing.
  5. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 22 Sep 2008 Link to this post

    Hello Filleau,

    You can choose either approach depending on your scenario. Other solution would be to use ItemDataBound event, but you will also have to check for nbsp content.

    Regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top