Add text % after textbox when edit it

6 posts, 0 answers
  1. Mr
    Mr avatar
    22 posts
    Member since:
    Oct 2008

    Posted 14 May 2009 Link to this post

    hi everyboday
    i am working with radgrid, and i using property AutoGenerateColumns="True" , and set data with DataSource,
    when i edit on grid i want to add Lable have text="%" after textbox when edit.
    i can't do it


    please help me
    thanks



  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 May 2009 Link to this post

    Hello,

    I guess you want to add a label (with Text as %) beside the textbox which is in edit mode. Try out the following code snippet.

    CS:
     
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
        {  
            GridEditableItem dataItem = e.Item as GridEditableItem;  
            Label lbl = new Label();  
            lbl.Text = "%";  
            dataItem["CategoryID"].Controls.Add(lbl); //CategoryID is the columnUniqueName 
        }       
    }  

    Thanks,
    Shinu.
  3. Mr
    Mr avatar
    22 posts
    Member since:
    Oct 2008

    Posted 15 May 2009 Link to this post

    thanks you
    but it still don't  Add text % after textbox when edit it

    please help me
    thanks
  4. Mr
    Mr avatar
    22 posts
    Member since:
    Oct 2008

    Posted 15 May 2009 Link to this post

    sorry
    thanks you
    yes. i have do it
  5. Mr
    Mr avatar
    22 posts
    Member since:
    Oct 2008

    Posted 16 May 2009 Link to this post

    but, in event UpdateCommand. how can i get control Label?

    i write same bellow

     protected void RadUpdateResource_UpdateCommand(object source, GridCommandEventArgs e)
     {
              GridEditableItem editedItem = e.Item as GridEditableItem;
              Lable Newlbl = (Label)editedItem["category"].FindControl("lbl");
    }

    but Newlbl = null

    please help me
    thanks

  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 May 2009 Link to this post

    Hi,

    Try adding the Label in ItemCreated event instead of ItemDataBound (including specifying the ID for Label) so that you can access it from UpdateCommand event.

    CS:
     
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
        {  
            GridEditableItem dataItem = e.Item as GridEditableItem;  
            Label lbl = new Label();  
            lbl.ID = "Label1";  
            lbl.Text = "%";  
            dataItem["CategoryID"].Controls.Add(lbl);      
        }  
    }  
    protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
    {  
        GridEditableItem editedItem = e.Item as GridEditableItem;  
        Label Newlbl = (Label)editedItem["CategoryID"].FindControl("Label1");  

    Thanks,
    Princy.
Back to Top