Hi all!
I have a problem with the event CreateColumnEditor of a RadGrid. My code has to generate a Column Editor for the TextBox a different one for the ComboBox. The problem is that the event is fired even if I haven't pressed the edit button yet. I can assure it because I did debug it. This happens only when I add the part of code that follows:
if (e.Column is GridDropDownColumn)......
Here there is the C# code:
protected void RadGrid_Processes_CreateColumnEditor(object sender, GridCreateColumnEditorEventArgs e)
{
Unit width;
String str;
if (e.Column is GridBoundColumn)
{
width = e.Column.HeaderStyle.Width;
str = (e.Column as GridBoundColumn).DataField;
int indexEditing=0;
bool even = true;
switch (entityType)
{
case "COMP":
if (str.Equals("Code"))
{
e.ColumnEditor = new TextBoxColumnEditor(10, true, str, width, true, true, hfCodes.Value, even);
}
break;
default:
break;
}
}
if (e.Column is GridDropDownColumn)
{
str = (e.Column as GridDropDownColumn).DataField;
switch (entityType)
{
case "CTRL":
if (str.Equals("FK_ControlType"))
{
e.ColumnEditor = new DropDownColumnEditor(true, str, true);
}
break;
default:
break;
}
}
}
Here there is the ASP.NET code:
<telerik:RadGrid ID="RadGrid_Processes" runat="server"
AutoGenerateColumns="False" DataSourceID="LinqDataSource_Entities"
oninit="RadGrid_Processes_Init"
onitemcreated="RadGrid_Processes_ItemCreated" GridLines="None"
onitemcommand="RadGrid_Processes_ItemCommand"
onitemdatabound="RadGrid_Processes_ItemDataBound"
onprerender="RadGrid_Processes_PreRender"
onneeddatasource="RadGrid_Processes_NeedDataSource"
ondatabinding="RadGrid_Processes_DataBinding" onload="RadGrid_Processes_Load"
OnCreateColumnEditor="RadGrid_Processes_CreateColumnEditor" >
<SelectedItemStyle CssClass="rgAltRow" />
<MasterTableView DataKeyNames="Id"
EditMode="InPlace" CommandItemDisplay="Bottom" InsertItemDisplay="Bottom" >
<EditFormSettings>
<FormTableItemStyle HorizontalAlign="Left" />
<FormTableAlternatingItemStyle HorizontalAlign="Left"/>
</EditFormSettings>
<ItemStyle CssClass="rgRow" Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
Wrap="True" />
<AlternatingItemStyle CssClass="rgAltRow" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
HorizontalAlign="Left" Wrap="True" />
<EditItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
Wrap="True" />
</MasterTableView>
</telerik:RadGrid>
Thanks in advance.
Kind regards,
Dario
I have a problem with the event CreateColumnEditor of a RadGrid. My code has to generate a Column Editor for the TextBox a different one for the ComboBox. The problem is that the event is fired even if I haven't pressed the edit button yet. I can assure it because I did debug it. This happens only when I add the part of code that follows:
if (e.Column is GridDropDownColumn)......
Here there is the C# code:
protected void RadGrid_Processes_CreateColumnEditor(object sender, GridCreateColumnEditorEventArgs e)
{
Unit width;
String str;
if (e.Column is GridBoundColumn)
{
width = e.Column.HeaderStyle.Width;
str = (e.Column as GridBoundColumn).DataField;
int indexEditing=0;
bool even = true;
switch (entityType)
{
case "COMP":
if (str.Equals("Code"))
{
e.ColumnEditor = new TextBoxColumnEditor(10, true, str, width, true, true, hfCodes.Value, even);
}
break;
default:
break;
}
}
if (e.Column is GridDropDownColumn)
{
str = (e.Column as GridDropDownColumn).DataField;
switch (entityType)
{
case "CTRL":
if (str.Equals("FK_ControlType"))
{
e.ColumnEditor = new DropDownColumnEditor(true, str, true);
}
break;
default:
break;
}
}
}
Here there is the ASP.NET code:
<telerik:RadGrid ID="RadGrid_Processes" runat="server"
AutoGenerateColumns="False" DataSourceID="LinqDataSource_Entities"
oninit="RadGrid_Processes_Init"
onitemcreated="RadGrid_Processes_ItemCreated" GridLines="None"
onitemcommand="RadGrid_Processes_ItemCommand"
onitemdatabound="RadGrid_Processes_ItemDataBound"
onprerender="RadGrid_Processes_PreRender"
onneeddatasource="RadGrid_Processes_NeedDataSource"
ondatabinding="RadGrid_Processes_DataBinding" onload="RadGrid_Processes_Load"
OnCreateColumnEditor="RadGrid_Processes_CreateColumnEditor" >
<SelectedItemStyle CssClass="rgAltRow" />
<MasterTableView DataKeyNames="Id"
EditMode="InPlace" CommandItemDisplay="Bottom" InsertItemDisplay="Bottom" >
<EditFormSettings>
<FormTableItemStyle HorizontalAlign="Left" />
<FormTableAlternatingItemStyle HorizontalAlign="Left"/>
</EditFormSettings>
<ItemStyle CssClass="rgRow" Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
Wrap="True" />
<AlternatingItemStyle CssClass="rgAltRow" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
HorizontalAlign="Left" Wrap="True" />
<EditItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
Wrap="True" />
</MasterTableView>
</telerik:RadGrid>
Thanks in advance.
Kind regards,
Dario