or
<EditFormSettings EditFormType="Template"> <FormTemplate> <div id="editdetail"> <h2> Truck information</h2> <table class="detailtable" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none" style="border-collapse: collapse;"> <tr> <td class="detaillabel"> Brand: </td> <td> <asp:PlaceHolder ID="phBrandComboBox" runat="server"></asp:PlaceHolder> </td> </tr> </table> </div> </FormTemplate></EditFormSettings>
In ItemDatBound I inject a UserControle containing a Telerik ComboBox in the PlaceHolder.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyTruckItemComboBox.ascx.cs"
Inherits="Truck_marketplace.MyPortfolio.User_controls.MyTruckItemComboBox" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>MyTruckItemComboBox</title>
</head>
<body>
<telerik:RadComboBox ID="cbMyTruckItemComboBox"
OnSelectedIndexChanged="cbMyTruckItemComboBox_SelectedIndexChanged"
runat="server">
</telerik:RadComboBox>
</body>
</html>
protected void grMyTruck_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is Telerik.Web.UI.GridEditableItem && e.Item.IsInEditMode)
{
// Insert + Edit mode.
Telerik.Web.UI.GridEditableItem EditItem = (Telerik.Web.UI.GridEditableItem)e.Item;
//Brand
MyPortfolio.User_controls.MyTruckItemComboBox ComboBoxBrand = (MyPortfolio.User_controls.MyTruckItemComboBox)LoadControl("MyTruckItemComboBox.ascx");
ComboBoxBrand.ID = "cbBrand";
ComboBoxBrand.GroupID = "BRD";
ComboBoxBrand.Languagecode = "en-US";
}
if (e.Item is Telerik.Web.UI.GridEditFormInsertItem || e.Item is Telerik.Web.UI.GridDataInsertItem)
{
// Insert mode
//Brand
ComboBoxBrand.BindComboBox2();
PlaceHolder phBrandComboBox = (PlaceHolder)e.Item.FindControl("phBrandComboBox");
phBrandComboBox.Controls.Add(ComboBoxBrand);
}
}
In the InsertCommand I the try to find the ComboBox and reading the SelectedValue from it. But I dont have any luck.
All of the code in the code here fails because the cb is null.
protected void grMyTruck_InsertCommand(object sender, GridCommandEventArgs e)
{
NMHG.Data.Truck_marketplace.Advert.Advert NewAdvert = new NMHG.Data.Truck_marketplace.Advert.Advert();
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem editableItem = e.Item as GridEditableItem;
UserControl userControl = editableItem.FindControl(GridEditFormItem.EditFormUserControlID) as UserControl;
Telerik.Web.UI.RadComboBox cb = userControl.FindControl("cbBrand") as Telerik.Web.UI.RadComboBox;
var temp = cb.SelectedValue;
PlaceHolder phBrandComboBox = (PlaceHolder)editableItem.FindControl("phBrandComboBox");
Telerik.Web.UI.RadComboBox cb2 = phBrandComboBox.FindControl("cbBrand") as Telerik.Web.UI.RadComboBox;
var temp2 = cb2.SelectedValue;
Telerik.Web.UI.RadComboBox cb3 = editableItem.FindControl("cbBrand") as Telerik.Web.UI.RadComboBox;
var temp3 = cb3.SelectedValue;
Telerik.Web.UI.RadComboBox cb4 = editableItem.FindControl("cbMyTruckItemComboBox") as Telerik.Web.UI.RadComboBox;
var temp4 = cb4.SelectedValue;
}
}
Can some one please help - Thanks.
I properly do some thing stupid so please bare with me ;-)
Anders Pedersen
| Protected Sub MyGrid_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles MyGrid.ItemDataBound |
| If e.Item.ItemType = GridItemType.Item Or e.Item.ItemType = GridItemType.AlternatingItem Then |
| Dim dataItem As GridDataItem = CType(e.Item, GridDataItem) |
| Dim currentRow As DataRowView = DirectCast(e.Item.DataItem, DataRowView) |
| For Each col As GridColumn In RadgridWinServerOSCount.Columns |
| If col.UniqueName = "columnOS" Then |
| Dim strTxt As String = currentRow.Row("Operating_System").ToString |
| Dim NewUrl As String |
| NewUrl = Server.UrlEncode(strTxt) |
| CType(dataItem("columnOS").Controls(0), HyperLink).NavigateUrl = "~/test.aspx?Os=" & NewUrl |
| End If |
| Next |
| End If |
| End Sub |

|
args.set_cancel(true);
sender._invalid = true;
sender.updateCssClass();
How to get the same behavior through code-behind, so that i can avoid writing JavaScript ?<html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <cc1:ABLDocumentDomain runat="server"> </cc1:ABLDocumentDomain> <div> <rad:RadAjaxManager ID="ctlAjaxMgr" runat="server"> <ClientEvents OnRequestStart="ABLControls_LockPage();" OnResponseEnd="ABLControls_UnlockPage();" /> <AjaxSettings> <rad:AjaxSetting AjaxControlID="ctlAjaxMgr"> <UpdatedControls> <rad:AjaxUpdatedControl ControlID="ctlCopy" LoadingPanelID="ctlLoadingPanel" /> </UpdatedControls> </rad:AjaxSetting> </AjaxSettings> </rad:RadAjaxManager> <%--Copy From Agency table--%> <table id="tblBoxHolder" cellspacing="2" style="border-right: #a9c6ee 2px solid; padding-right: 0px; border-top: #a9c6ee 2px solid; padding-left: 0px; padding-bottom: 0px; margin: 0px; border-left: #a9c6ee 2px solid; padding-top: 0px; border-bottom: #a9c6ee 2px solid; height: 1px;" width="50%"; align="center"> <tr> <%--Table Header--%> <td align="right" colspan="2" style="height: 10px; text-align: Center; vertical-align: middle; background-color: #a9c6ee; font-weight: bold;"> Copy Spec Sheets From Agency: </td> </tr> <tr> <%--From Agency label and combobox rows--%> <td class="style3"> Rep #: </td> <td style="width: 80%"> <rad:RadComboBox ID="ctlViewFromAgencyRepCombo" runat="server" AutoPostBack="true" AppendDataboundItems = "true" DataSourceID="odsRepNumFromAgency" DataTextField="REP_NUMBER" DataValueField="REP_NUMBER" Skin="ABL_Std" SkinsPath="~/RadControls/ComboBox/Skins" Width="320px" Height="200px" OnSelectedIndexChanged="ctlViewFromAgencyRepCombo_SelectedIndexChanged"> <Items> <rad:RadComboBoxItem Text="-- Select One --" Value="-1" /> </Items> </rad:RadComboBox> </td> </tr> <tr> <%--Copy To Agency table--%> <table id="Table2" cellspacing="2" style="border-right: #a9c6ee 2px solid; padding-right: 0px; border-top: #a9c6ee 2px solid; padding-left: 0px; padding-bottom: 0px; margin: 0px; border-left: #a9c6ee 2px solid; padding-top: 0px; border-bottom: #a9c6ee 2px solid; height: 1px;" width="50%", align="center";> <tr> <td align="right" colspan="2" style="height: 10px; text-align: Center; vertical-align: middle; background-color: #a9c6ee; font-weight: bold;"> Copy Spec Sheets To Agency: </td> </tr> <tr> <%--To Agency label and combobox rows (dependent on selected rep). DataID and binding info is in the codebehind.--%> <td class="style3"> Rep #: </td> <td style="width: 80%"> <rad:RadComboBox ID="ctlViewToAgencyRepCombo" runat="server" AutoPostBack="true" AppendDataboundItems = "true" Skin="ABL_Std" SkinsPath="~/RadControls/ComboBox/Skins" Width="320px" enabled="false" OnSelectedIndexChanged="CopyCheck" Height="200px"> <Items> <rad:RadComboBoxItem Text="-- Select One --" Value="-1" /> </Items> </rad:RadComboBox> </td> </tr> <%--Close and Copy buttons--%> </table> <br /> <br /> <table width="50%", align="center"> <tr> <td align="center"> <asp:Button ID="ctlCopy" runat="server" Text="Copy" Visible="True" style="width: 95px;" enabled="false" OnClick="ctlCopy_CopySpecSheets" /> <asp:Button ID="ctlClose" runat="server" Text="Close" Visible="True" style="width: 95px;" onclientclick="CloseForm()" /> </td> </tr> </table> <rad:AjaxLoadingPanel ID="ctlLoadingPanel" runat="server" Height="75px" MinDisplayTime="1000" Transparency="5" Width="75px"> <asp:Image ID="Image1" runat="server" AlternateText="Loading..." ImageUrl="~/Images_ABL_Std/Grid/loading.gif" /> </rad:AjaxLoadingPanel> </div>