I am facing problem in event fire up in item update... of RAD Grid. Can you please anybody help me to solve this issue.
This is my Page Design Source :
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<title>Untitled Page</title>
</
head>
<
style type="text/css">
.MyImageButton
{
cursor: hand;
}
.EditFormHeader td
{
font-size: 14px;
padding: 4px !important;
color: #0066cc;
}
</
style>
<
body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function RowDblClick(sender, eventArgs)
{
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
</script>
</
telerik:RadCodeBlock>
<
telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="gridFXCustomersConfig">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gridFXCustomersConfig" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</
telerik:RadAjaxManager>
<
table cellspacing="0" cellpadding="2" border="0" width="100%" summary="KIBFXRates Settings Design Table">
<tr>
<td class="SubHead">
<%
-- <dnn:Label ID="lblFXCustomersConfig" runat="server" ControlName="txtTemplate" Suffix=":">
</dnn:Label>--
%>
</td>
<td valign="bottom">
<telerik:RadGrid ID="gridFXCustomersConfig" runat="server" AllowPaging="True" PageSize="10"
AutoGenerateColumns="False" AllowAutomaticUpdates="true" AllowAutomaticInserts="true" AllowAutomaticDeletes="true" Width="100%" ShowStatusBar="true" Skin="WebBlue"
OnPreRender="gridFXCustomersConfig_PreRender" OnItemUpdated="gridFXCustomersConfig_ItemUpdated"
OnItemCommand="gridFXCustomersConfig_ItemCommand" OnDataBound="gridFXCustomersConfig_DataBound">
<MasterTableView Width="100%" CommandItemDisplay="Bottom" DataKeyNames="crncy_id" EnableViewState="true"
EditMode="InPlace">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
<ItemStyle CssClass="MyImageButton" />
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="crncy_id" UniqueName="crncy_id" HeaderText="Currency ID"
Visible="false">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn AllowFiltering="false">
<ItemTemplate>
<asp:Image ID="imgFlag" runat="server" ImageUrl='<%# String.Format("~/images/FXFlags/{0}",Eval("iso_code")+".gif") %>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="iso_code" UniqueName="iso_code" HeaderText="Coun.Code"
ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="description_english" UniqueName="description_english"
HeaderText="Country" ItemStyle-Wrap="false" ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn UniqueName="chBuyTransfer" HeaderText="Buy Transfer Vs.KD.">
</telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn UniqueName="chSellTransfer" HeaderText="Sell Transfer Vs.KD.">
</telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn UniqueName="chBuyCash" HeaderText="Buy Cash Vs.KD.">
</telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn UniqueName="chSellCash" HeaderText="Sell Cash Vs.KD.">
</telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn UniqueName="chRate" HeaderText="Rate">
</telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn UniqueName="chLCSelling" HeaderText="LC Selling">
</telerik:GridCheckBoxColumn>
</Columns>
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
<EditFormSettings ColumnNumber="2" CaptionDataField="crncy_id" CaptionFormatString="Edit properties of Column {0}">
<FormTableItemStyle Wrap="False"></FormTableItemStyle>
<FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
<FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
Width="100%" />
<FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
<EditColumn ButtonType="ImageButton" UpdateText="Update record" UniqueName="EditCommandColumn1"
CancelText="Cancel edit">
</EditColumn>
<FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
</EditFormSettings>
</MasterTableView>
<ClientSettings EnablePostBackOnRowClick="true">
<ClientEvents OnRowDblClick="RowDblClick" />
</ClientSettings>
</telerik:RadGrid>
</td>
</tr>
</
table>
</div>
</form>
</
body>
</
html>
And This is my CS Code :
public
partial class Default2 : System.Web.UI.Page
{
private DataSet dsFXCustomers;
private DataSet dsFXStaff;
private long lngApplicationNumber;
private string strNovellUserName;
private string strNovellUserPassword;
private string strURL;
private string strLoginState;
protected void Page_Init(object sender, EventArgs e)
{
this.gridFXCustomersConfig.ItemUpdated+=new GridUpdatedEventHandler(gridFXCustomersConfig_ItemUpdated);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Session["FXConfig"] == null)
{
Session[
"FXConfig"] = GetFXConfigData();
}
////For Customers
DataTable dtFXCustomerData = Session["FXConfig"] as DataTable;
dtFXCustomerData.DefaultView.RowFilter =
"exch_Index_type Not like 'Staff'";
gridFXCustomersConfig.DataSource = dtFXCustomerData;
gridFXCustomersConfig.Rebind();
}
}
public DataTable GetFXConfigData()
{
try
{
strURL =
Convert.ToString(ConfigurationManager.AppSettings["IAWS_PHOENIX.IAWS_PHOENIX"]);
if (strURL != null)
{
IAWS_PHOENIX.IntelligentApplicationsWebServicesPhoenix webService =
new IAWS_PHOENIX.IntelligentApplicationsWebServicesPhoenix();
webService.Url = strURL;
lngApplicationNumber = 1;
dsFXCustomers = webService.IAWS_CURRENCY_EXCHANGE_RATE(lngApplicationNumber, IAWS_PHOENIX.gEnum_Phoenix_ListOfTransactions.TRX_602_PHOENIX_CURRENCY_EXCHANGE_RATE,
"devwebportal", "cherry123", "dev", "phoenix", null, 0);
strLoginState = dsFXCustomers.Tables[0].Rows[0][0].ToString();
if (strLoginState.Contains("SUCCESS"))
return dsFXCustomers.Tables[1];
}
return null;
}
catch (Exception exMsg)
{
//Exceptions.LogException(exMsg);
throw exMsg;
}
}
protected void gridFXCustomersConfig_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
////For Customers
DataTable dtFXCustomerData = Session["FXConfig"] as DataTable;
dtFXCustomerData.DefaultView.RowFilter =
"exch_Index_type Not like 'Staff'";
gridFXCustomersConfig.DataSource = dtFXCustomerData;
gridFXCustomersConfig.Rebind();
}
protected void gridFXCustomersConfig_PreRender(object sender, EventArgs e)
{
foreach (GridCommandItem cmditm in gridFXCustomersConfig.MasterTableView.GetItems(GridItemType.CommandItem))
{
if (gridFXCustomersConfig.Items.Count > 0)
{
Button btn1 = (Button)cmditm.FindControl("AddNewRecordButton");
if (btn1 != null)
{
btn1.Visible =
false;
LinkButton lnkbtn1 = (LinkButton)cmditm.FindControl("InitInsertButton");
lnkbtn1.Visible =
false;
}
}
}
}
protected void gridFXCustomersConfig_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
{
System.Diagnostics.
Debugger.Break();
GridEditableItem item = (GridEditableItem)e.Item;
String id = item.GetDataKeyValue("crncy_id").ToString();
if (e.Exception != null)
{
e.KeepInEditMode =
true;
e.ExceptionHandled =
true;
SetMessage(
"Row with ID " + id + " cannot be updated. Reason: " + e.Exception.Message);
}
else
{
SetMessage(
"Row with ID " + id + " is updated!");
}
}
private void DisplayMessage(string text)
{
gridFXCustomersConfig.Controls.Add(
new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text)));
}
private void SetMessage(string message)
{
gridMessage = message;
}
private string gridMessage = null;
protected void gridFXCustomersConfig_DataBound(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(gridMessage))
{
DisplayMessage(gridMessage);
}
}
}
Thanks in Advance.
Sheik.