<telerik:GridTemplateColumn UniqueName="ddHeader" HeaderText="Header"> |
<EditItemTemplate> |
<asp:DropDownList ID="HeaderDropDown" runat="server" /> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
private void Grid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridEditableItem) |
{ |
GridEditableItem item = e.Item as GridEditableItem; |
Dictionary<string, string> dict = new Dictionary<string, string>(); |
dict = ReadHeader(); |
DropDownList list =item.FindControl("HeaderDropDown") as DropDownList; |
list.DataSource = dict; |
list.DataBind(); |
} |
} |
I've seen a ton of questions on this, however no simple explanations why this is occurring or what the solution to the problem is.
We've got a Batch Edit Update Grid that I originally had a RadComboBox in that was working fine until I found that keyboard navigation was screwing up the keyboard flow and saw that it was recommended to switch to a RadDropDown control, so I did, which is in a GridTemplateColumn similar to this:
<
telerik:RadGrid
ID
=
"RadGrdActionInputs"
runat
=
"server"
Width
=
"900px"
OnNeedDataSource
=
"RadGrdActionGroupInputs_NeedDataSource"
AutoGenerateColumns
=
"False"
RenderMode
=
"Lightweight"
AllowSorting
=
"True"
OnItemDataBound
=
"RadGrdActionInputs_ItemDataBound"
oninsertcommand
=
"RadGrdActionInputs_InsertCommand"
onupdatecommand
=
"RadGrdActionInputs_UpdateCommand"
ondeletecommand
=
"RadGrdActionInputs_DeleteCommand"
oneditcommand
=
"RadGrdActionInputs_EditCommand"
AutoGenerateEditColumn
=
"True"
>
<
GroupingSettings
CollapseAllTooltip
=
"Collapse all groups"
></
GroupingSettings
>
<
MasterTableView
CommandItemDisplay
=
"TopAndBottom"
DataKeyNames
=
"ID"
EditMode
=
"Batch"
>
<
BatchEditingSettings
EditType
=
"Row"
/>
<
CommandItemSettings
ShowCancelChangesButton
=
"true"
ShowRefreshButton
=
"false"
/>
....
<
telerik:GridTemplateColumn
HeaderText
=
"Data Point"
DataField
=
"DataPointID"
HeaderStyle-Width
=
"500px"
>
<
ItemTemplate
>
<
telerik:RadTextBox
ID
=
"RadTextBox1"
runat
=
"server"
Width
=
"150px"
></
telerik:RadTextBox
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDropDownList
RenderMode
=
"Lightweight"
ID
=
"ddDataPointList"
runat
=
"server"
Width
=
"300px"
>
</
telerik:RadDropDownList
>
</
EditItemTemplate
>
<
HeaderStyle
Width
=
"500px"
></
HeaderStyle
>
</
telerik:GridTemplateColumn
>
In the examples and the problems/posts that I have seen, they all recommend checking the e.item type in the ItemDataBound event. If the e.item is a GridDataItem then bind a label, else if it's a GridEditableItem bind the dropdown, IE:
protected
void
RadGrdActionInputs_ItemDataBound(
object
sender, GridItemEventArgs e)
{
//get combobox data for drop down.
DataPointsModel dataPointsModel = ConfigurationController.GetAllDataPoints();
try
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
RadLabel lblActionGroupType = item.FindControl(
"lblDataPoint"
)
as
RadLabel;
//get value for ActionGroupTypeID
string
val = DataBinder.Eval(item.DataItem,
"DataPointID"
).ToString();
}
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
RadDropDownList rddl = item.FindControl(
"ddDataPointList2"
)
as
RadDropDownList;
BindRadDropDownDataList(
"I"
, rddl,
"Name"
,
"ID"
);
}
}
catch
{}
}
Problem is, this code never gets called:
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
RadDropDownList rddl = item.FindControl(
"ddDataPointList2"
)
as
RadDropDownList;
BindRadDropDownDataList(
"I"
, rddl,
"Name"
,
"ID"
);
}
I'm pulling my hair out on this one..
Given the following object structure...
public class CategoryViewModel
{
public int category_id {get; set;}
public string category_name {get; set;}
public List<CategoryDetailsViewModel> details { get; set; }
}
public class CategoryDetailsViewModel
{
public string category_detail_id {get; set;}
public string category_admin {get; set;}
}
Is it possible to use a DetailTable where the details are defined in the parent object? For example, I've tried this, though all the detail tables were empty:
<telerik:RadGrid runat="server" ID="rgCategories" OnNeedDataSource="rgCategories_NeedDataSource" Skin="Silk" AutoGenerateColumns="false">
<MasterTableView>
<DetailTables>
<telerik:GridTableView Name="Category Details">
<Columns>
<telerik:GridBoundColumn HeaderText="Category Admin" DataTextField="details.category_admin"></telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn HeaderText="Category" DataField="category_name"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Does anyone know of a way to easily prevent double clicking the next button. e.g. I dont want to charge the user's credit card twice.
Any help would be great. Thanks!
I have a situation where users need to edit previously entered data, which might not be valid. For example, assume the valid range for an invoice date is the current month (10/1/2017 to 10/31/2017). Also assume I have an existing invoice with a date outside that range (11/5/2017). I'd like to present the invalid value to the user, and have the min/max validation force them to fix it.
Ideally, I could just set the min, max, and selected values in the code behind, and let the client side validation do it's job. However, setting the selected date to the invalid date in the code behind throws an exception. I also tried setting the selected date first, then applying the min/max...but then it changes the selected date based on the min/max. And the InvalidTextBoxValue is read only, so that's not an option.
Is there a way to have the initial date value be an invalid value? I used the example of a date being outside the min/max range...but in our situation it's possible that the original value wouldn't even be a valid date. Is there anything built into the control that would help with this situation? One option would be to not use the built in min/max...and implement my own client side validation to do the range check. But I view that as a last resort.
I have the following code as part of FormTemplate.
<
tr
>
<
td
>Body EN:
</
td
>
<
td
>
<
telerik:RadEditor
ID
=
"txtBodyEN"
runat
=
"server"
Height
=
"400px"
Width
=
"100%"
ToolsFile
=
"~/Tools.xml"
Content='<%# Bind("BodyEN") %>' RenderMode="Lightweight" Skin="MetroTouch" EnableTrackChanges="false" EnableComments="false" EnableViewState="false">
</
telerik:RadEditor
>
</
td
>
</
tr
>
<
tr
>
<
td
>Body DE:
</
td
>
<
td
>
<
telerik:RadEditor
ID
=
"txtBodyDE"
runat
=
"server"
Height
=
"400px"
Width
=
"100%"
ToolsFile
=
"~/Tools.xml"
Content='<%# Bind("BodyDE") %>' RenderMode="Lightweight" Skin="MetroTouch" EnableTrackChanges="false" EnableComments="false" EnableViewState="false">
</
telerik:RadEditor
>
</
td
>
</
tr
>
<
tr
>
<
td
></
td
>
<
td
>
<
telerik:RadButton
runat
=
"server"
ID
=
"btnCancel"
Text
=
"Cancel"
CommandName
=
"Cancel"
Skin
=
"MetroTouch"
RenderMode
=
"Lightweight"
Icon-PrimaryIconCssClass
=
"rbCancel"
UseSubmitBehavior
=
"false"
/>
<
telerik:RadButton
runat
=
"server"
ID
=
"btnUpdate"
Text='<%# (Container is GridEditFormInsertItem) ? "Add" : "Save" %>' CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' Skin="MetroTouch" RenderMode="Lightweight" Primary="true" Icon-PrimaryIconCssClass="rbOk" UseSubmitBehavior="false" />
</
td
>
</
tr
>
It works fine in IE but in Chrome it throws an exception as soon as you click the cancel button:
System.Web.HttpException: Maximum request length exceeded.
I've tried everything and none of those worked for me.
Note: if I remove the RadEditor's from there the Cancel button works fine in Chrome too.
Thanks
P.S. I am using a trial (current version)