I have a RadGrid that is using AutoGenerated templates for INSERT and UPDATE.
Whether it is EditMode="InPlace" or not, how do you change the TextBox or control's widths and their fonts?
Currently the EditMode property is not set which defaults to an Edit Template. I am just not sure how to get that template and it's controls to alter their styles.
Thanks
Whether it is EditMode="InPlace" or not, how do you change the TextBox or control's widths and their fonts?
Currently the EditMode property is not set which defaults to an Edit Template. I am just not sure how to get that template and it's controls to alter their styles.
Thanks
4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 19 Apr 2011, 10:00 AM
Hello,
You can change the style of controls using following code.Hope this might help you.
ASPX:
C#:
Thanks,
Princy
You can change the style of controls using following code.Hope this might help you.
ASPX:
<telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name"> </telerik:GridBoundColumn>C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))//if EditMode is 'EditForms/PopUp' { GridEditFormItem editItem = e.Item as GridEditFormItem; TextBox txtname = (TextBox)editItem["Name"].Controls[0]; txtname.Width = Unit.Pixel(30); } }Thanks,
Princy
0
Reid
Top achievements
Rank 2
answered on 19 Apr 2011, 02:15 PM
Thank you, that did it.
Do you happen to know how to iterate through a GridEditForm's controls? Rather than placing the same redundant code in every ItemDataBound handler, as well as needing to refer to them by name. I would like to use a HTMLHelper class to format controls. The code below does not work. Do you know how to do this?
Thanks,
Reid
Do you happen to know how to iterate through a GridEditForm's controls? Rather than placing the same redundant code in every ItemDataBound handler, as well as needing to refer to them by name. I would like to use a HTMLHelper class to format controls. The code below does not work. Do you know how to do this?
public static void FormatEditControls(GridEditFormItem formItem) { foreach (Control item in formItem.Controls) { if (item is TextBox) { TextBox txtBox = (TextBox) item; txtBox.Width = Unit.Pixel(200); txtBox.Font.Name = "MsSanSerif"; txtBox.Font.Size = FontUnit.Point(9); txtBox.Font.Bold = false; } if (item is RadTextBox) { } } }Thanks,
Reid
0
Princy
Top achievements
Rank 2
answered on 20 Apr 2011, 10:47 AM
Hello,
The following code helps you to iterate through each GridEditForm. Hope this helps you.
C#:
Thanks,
Princy
The following code helps you to iterate through each GridEditForm. Hope this helps you.
C#:
foreach(GridEditFormItem editItem in RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem))//loops throgh all RadGrid edit row { //your code }Thanks,
Princy
0
Reid
Top achievements
Rank 2
answered on 20 Apr 2011, 03:07 PM
Works fine, thank you much!