<EditFormSettings EditFormType="Template"> <FormTemplate> <table style="width: 100%;"> <tr> <td align="left" width="25%"> <asp:Label ID="MadeDteLabel" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" Text="Agreement Made:"></asp:Label> </td> <td align="left" width="25%"> <telerik:RadDatePicker ID="MadeDatePicker" runat="server" Skin="Web20"> <Calendar runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x" Skin="Web20"> </Calendar> <DateInput runat="server" DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"> </DateInput> <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton> </telerik:RadDatePicker> </td> <td align="left" width="25%"> <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" Text="RebateType:"></asp:Label> </td> <td align="left" colspan="2" width="25%"> <telerik:RadComboBox ID="RebTypComboBox" runat="server" DataTextField="rebateType" DataValueField="rebateTypeID" Skin="Web20" Width="150px"> <Items> <telerik:RadComboBoxItem runat="server" Text="--" Value="0" Selected="true" /> </Items> </telerik:RadComboBox> </td> </tr> <tr> <td align="left" width="25%"> <asp:Label ID="RevDteLabel" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" Text="Rebate Revision Date:"></asp:Label> </td> <td align="left" width="25%"> <telerik:RadDatePicker ID="RevDatePicker" runat="server" Skin="Web20"> <Calendar runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x" Skin="Web20"> </Calendar> <DateInput runat="server" DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"> </DateInput> <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton> </telerik:RadDatePicker> </td> <td align="left" width="25%"> <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" Text="Rebate Amount:"></asp:Label> </td> <td align="left" colspan="2" width="25%"> <telerik:RadNumericTextBox ID="RebateAmt" runat="server" Text='<%# Bind("rebate_amount") %>' Skin="Web20" Width="70px"> </telerik:RadNumericTextBox> </td> </tr> <tr> <td align="left" width="25%"> </td> <td align="left" width="25%"> <asp:CheckBox ID="AgentRebApplyAllCB" runat="server" AutoPostBack="true" Font-Names="Arial" Font-Size="X-Small" OnCheckedChanged="AgentRebApplyAllCB_CheckedChanged" Text="Apply To All Ports" /> </td> <td align="left" width="25%"> </td> <td align="left" colspan="2" width="25%"> <asp:Label ID="RebORLabel0" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" Text="Rate Terms:"></asp:Label> </td> </tr> <tr> <td align="left" width="25%"> <asp:Label ID="RebAPLabel" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" Text="Applicable Port:"></asp:Label> </td> <td align="left" width="25%"> <telerik:RadComboBox ID="RebAppPortComboBox" runat="server" Skin="Web20"> </telerik:RadComboBox> </td> <td align="left" width="25%"> </td> <td align="left" colspan="2" width="25%"> <telerik:RadComboBox ID="RebTermComboBox" runat="server" DataTextField="term_type" DataValueField="termID" Skin="Web20" Width="150px"> <Items> <telerik:RadComboBoxItem runat="server" Text="--" Value="0" Selected="true" /> <telerik:RadComboBoxItem runat="server" Text="Weekly" Value="1" /> <telerik:RadComboBoxItem runat="server" Text="Monthly" Value="2" /> <telerik:RadComboBoxItem runat="server" Text="Quaterly" Value="3" /> <telerik:RadComboBoxItem runat="server" Text="Half Year" Value="4" /> <telerik:RadComboBoxItem runat="server" Text="Yearly" Value="5" /> </Items> </telerik:RadComboBox> </td> </tr> <tr> <td align="left" width="25%"> </td> <td align="left" width="25%"> </td> <td align="left" width="25%"> </td> <td align="left" colspan="2" width="25%"> </td> </tr> <tr> <td align="left" width="25%"> </td> <td align="left" width="25%"> </td> <td align="left" width="25%"> </td> <td align="left" style="width: 12.5%" width="12.5%"> <telerik:RadButton ID="btnUpdate" CommandName='<%# Iif (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>' runat="server" Skin="Web20" Text='<%# Iif (TypeOf Container is GridEditFormInsertItem, "Insert", "Update") %>'> </telerik:RadButton> </td> <td align="left" style="width: 12.5%" width="12.5%"> <telerik:RadButton ID="btnCancel" runat="server" Skin="Web20" CausesValidation="false" CommandName="Cancel" Text="Cancel"> </telerik:RadButton> </td> </tr> </table> </FormTemplate> </EditFormSettin

We have a radgrid that gets bound in 2 different ways. This depends on what action has been performed on the page..e.g
1. select comboboxA - will bind radgrid via server side binding using NeedDataSource event
2. select comboboxB - will bind radgrid via page method + client side binding . Below are are the the main 2 javascript functions in use .
function GetDataForGrid() { PageMethods.GetDataForGrid(GetDataForGridBy_Result, GetDataForGridByHeader_Failed);}
function GetDataForGrid_Result(result) {
var tableView = $find("<%=RadGrid.ClientID %>").get_masterTableView();
tableView.set_dataSource(result.Value);
tableView.dataBind();
}
The problem is, after the client side binding, if the user clicks on a certain row we need to do some processing in a server side event - RadGrid_ItemCommand(object sender, GridCommandEventArgs e) ...
However when we obtain the datakey within this server side event, it is always wrong....
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" /></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <%--Needed for JavaScript IntelliSense in VS2010--%> <%--For VS2008 replace RadScriptManager with ScriptManager--%> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> </Scripts> </telerik:RadScriptManager> <script type="text/javascript"> function yo(sender, e) { radopen("test.aspx", null); } </script> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> </telerik:RadAjaxManager> <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" RestrictionZoneID="RestrictionZone" ShowContentDuringLoad="False"> <Windows> <telerik:RadWindow ID="win1" runat="server" VisibleStatusbar="false" Behaviors="Close,Move" Width="750px" Height="400px" Modal="true" Title="I'm not working" /> </Windows> </telerik:RadWindowManager> <div> <telerik:RadButton ID="yo" runat="server" Text="yo" AutoPostBack="false" OnClientClicked="yo"> </telerik:RadButton> </div> </form></body></html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <script type="text/javascript"> function here(sender, e) { var win = GetRadWindow().BrowserWindow; win.radopen(null, "win1"); // Open a window that is define in the radWindowManager of the parentPage } // Donne la référence d'une fenêtre radWindow function GetRadWindow() { var oWindow = null; if (window.radWindow) oWindow = window.radWindow; else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; return oWindow; } </script></head><body> <form id="form1" runat="server"> <div> <telerik:RadButton ID="but1" runat="server" AutoPostBack="false" Text="Click here Dude!" OnClientClicked="here"> </telerik:RadButton> <telerik:RadScriptManager runat="server"></telerik:RadScriptManager> <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_needDS"> <MasterTableView AutoGenerateColumns="false" Name="test" CommandItemDisplay="Top" DataKeyNames="Id"> <CommandItemTemplate> <telerik:RadToolBar ID="RadToolBarGrid" runat="server" OnClientButtonClicking="here"> <Items> <telerik:RadToolBarButton Text="Add new" ImageUrl="~/Images/Add.png"> </telerik:RadToolBarButton> </Items> </telerik:RadToolBar> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn DataField="Id" HeaderText="Id" UniqueName="Id"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Style" HeaderText="Style" UniqueName="Style"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Rating" HeaderText="Rating" UniqueName="Rating"> </telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> </div> </form></body></html>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace RadControlsWebApp5{ public partial class test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void RadGrid1_needDS(object sender, EventArgs e) { List<movie> movies = new List<movie>(); movies.Add(new movie(1, "King Kong", "Action", "4/5")); movies.Add(new movie(2, "The Black Knight", "Action", "4.5/5")); movies.Add(new movie(3, "Harry Potter and the deadly hallow", "Fantasy", "4/5")); movies.Add(new movie(4, "Inception", "Sc-fiction", "5/5")); movies.Add(new movie(5, "Transformer : The revenge of the fallen", "Action, Sc-Fiction", "3/5")); RadGrid1.DataSource = movies; } } public class movie { public movie(int id, string title, string style, string rating) { Id = id; Title = title; Style = style; Rating = rating; } public int Id { get; private set; } public string Title { get; private set; } public string Style { get; private set; } public string Rating { get; private set; } }}