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

Add text % after textbox when edit it

5 Answers 158 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mr
Top achievements
Rank 1
Mr asked on 15 May 2009, 04:07 AM
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



5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 May 2009, 06:49 AM
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.
0
Mr
Top achievements
Rank 1
answered on 15 May 2009, 08:32 AM
thanks you
but it still don't  Add text % after textbox when edit it

please help me
thanks
0
Mr
Top achievements
Rank 1
answered on 15 May 2009, 08:45 AM
sorry
thanks you
yes. i have do it
0
Mr
Top achievements
Rank 1
answered on 16 May 2009, 07:28 AM
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

0
Princy
Top achievements
Rank 2
answered on 19 May 2009, 09:42 AM
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.
Tags
TreeView
Asked by
Mr
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mr
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or