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

Want to put default value and readonly textbox when edit or insert button press

2 Answers 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Syed
Top achievements
Rank 1
Syed asked on 07 May 2009, 11:13 PM
Hi,

How to put  a default value in textbox in a EditMode form when an "Add a new Record" or "Edit" button is pressed. I want these textbox to be readonly.

i want to see this one programtically. And also please write what event fires when i press edit and insert button.

Thanks.

Regards
Arshad

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 08 May 2009, 04:35 AM
Hi Syed,

Try the following code snippet for assigning a default value and to disable the textbox when either in editmode or in insert mode.

CS:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
    { 
        GridEditableItem insertedItem = (GridEditableItem)e.Item; 
        TextBox textbox = (TextBox)insertedItem["CategoryID"].Controls[0]; 
        textbox.Text = "Custom Text"
        textbox.Enabled = false
    } 

Thanks,
Shinu.
0
Syed
Top achievements
Rank 1
answered on 08 May 2009, 02:28 PM
Sorry, i could not able to explain my question properly here. 

I have a normal ASP.NET textbox control displaying on the page which contains certain value, everytime whenever a new row is inserted in the RadGrid, this normal textbox value will be added to this particular column of the grid.  And also i want RadGrid which iam adding the value should be invisible.

As the below, i need in this type:
insertedItem["CategoryID"].Controls[0]=textbox1.text 

 
I guess my question is still confusing.

Thanks.

Regards
Syed Arshad
Tags
Grid
Asked by
Syed
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Syed
Top achievements
Rank 1
Share this question
or