
<%@ Page Title="" Language="C#" MasterPageFile="~/APPmaster.master" AutoEventWireup="true" CodeFile="FacultyAdvisorBulkUpload.aspx.cs" Inherits="Common.Common_FacultyAdvisorBulkUpload" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <script type="text/javascript"> function DownloadTemplate() { var url = '../Common/Templates/FacultyAdvisors.csv'; //location.href = url; window.open(url, 'Download'); } </script> <script type="text/javascript"> // This function helps to make the page tab fit the height of RadGrid function GridCreated(sender, args) { //alert(document.getElementById(sender.get_id()).clientHeight); var gridObj = document.getElementById(sender.get_id()); var tabObj = document.getElementById('<%=RadMultiPage.ClientID %>'); var searchObj = document.getElementById('search-area'); tabObj.style.height = (gridObj.clientHeight + searchObj.clientHeight) + 'px'; } // When clicking export, disable the AJAX function onRequestStart(sender, args) { if (args.get_eventTarget().indexOf("ExportTo") >= 0) { args.set_enableAjax(false); } } </script> <br /><br /> <telerik:RadTabStrip runat="server" ID="RadTabStrip" Skin="Outlook" SelectedIndex="0" MultiPageID="RadMultiPage"> <Tabs> <telerik:RadTab Text="Advisor List" ToolTip="View Faculty Advisor Relationship" /> <telerik:RadTab Text="Advisor Bulk Update" ToolTip="Tool to Import Grades to APP." runat="server" /> </Tabs> </telerik:RadTabStrip> <telerik:RadMultiPage runat="server" ID="RadMultiPage" SelectedIndex="0" CssClass="pageView"> <telerik:RadPageView runat="server" ID="RadPageView" > <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Hay"> </telerik:RadAjaxLoadingPanel> <div id="search-area" style="padding:10px 0 20px 0;"> <b>Faculty Name:</b> <telerik:RadTextBox ID="FacultyNameCond" runat="server" /> <b>Student Name:</b> <telerik:RadTextBox ID="StudentNameCond" runat="server" /> <b>Class:</b> <telerik:RadComboBox ID="ClassCond" runat="server" ViewStateMode="Enabled" /> <telerik:RadButton ID="SearchButton" runat="server" Text="Search" OnClick="SearchButton_Click" /> <telerik:RadButton ID="ExportButton" runat="server" Text="Export to XLS" OnClick="ExportButton_Click" /> </div> <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1" ClientEvents-OnRequestStart="onRequestStart"> <telerik:RadGrid runat="server" ID="RadGridAdvisorList" Skin="Hay" Width="900px" GridLines="None" OnItemDataBound="RadGridAdvisorList_ItemDataBound" AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="false" HeaderStyle-Font-Bold="true" HeaderStyle-Font-Size="Small"> <PagerStyle Mode="NextPrevAndNumeric" /> <MasterTableView DataKeyNames="ID" ClientDataKeyNames="ID" PageSize="10" AllowMultiColumnSorting="true"> <GroupByExpressions> <telerik:GridGroupByExpression> <GroupByFields> <telerik:GridGroupByField FieldName="FacultyName" /> </GroupByFields> <SelectFields> <telerik:GridGroupByField FieldName="FacultyName" /> </SelectFields> </telerik:GridGroupByExpression> </GroupByExpressions> <CommandItemSettings ShowAddNewRecordButton="false" /> <Columns> <telerik:GridBoundColumn DataField="FacultyName" HeaderText="Faculty Name" Display="false" /> <telerik:GridBoundColumn DataField="FacultyID" HeaderText="Faculty Email" Display="false" /> <telerik:GridImageColumn DataType="System.String" DataImageUrlFields="ImageLink" DataImageUrlFormatString="~/Pics/{0}" AlternateText="Student image" DataAlternateTextField="StudentName" ImageAlign="Middle" ImageWidth="57px" ImageHeight="72px" AllowFiltering="false" HeaderStyle-Width="64px" /> <telerik:GridBoundColumn DataField="StudentName" HeaderText="Student Name" AllowFiltering="false" HeaderStyle-Width="160px" /> <telerik:GridBoundColumn DataField="StudentID" HeaderText="Student ID" AllowFiltering="false" HeaderStyle-Width="90px" /> <telerik:GridBoundColumn DataField="Email" HeaderText="Email" AllowFiltering="false" HeaderStyle-Width="160px" /> <telerik:GridBoundColumn DataField="Status" HeaderText="Status" AllowFiltering="false" HeaderStyle-Width="160px" /> <telerik:GridBoundColumn DataField="Class" HeaderText="Class" AllowFiltering="false" HeaderStyle-Width="90px" /> <%-- <telerik:GridTemplateColumn> <ItemTemplate> <input type="image" src="../Styles/Images/Snapshot.gif" alt="Select" /> </ItemTemplate> </telerik:GridTemplateColumn> --%> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> <ClientEvents OnGridCreated="GridCreated" /> </ClientSettings> </telerik:RadGrid> </telerik:RadAjaxPanel> </telerik:RadPageView> <telerik:RadPageView runat="server" ID="BulkUploadView"> <div class="pageTitle"><b>Advisor Bulk Update</b></div> <div id="ContainerDiv" class="legendBorderStaff" style="Height: 200px;"> <div class="tabWrapper"> <div class="regularLabel"> 1. Download Template (if necessary): <br /> <button id="btnTemplate" onclick="javascript:DownloadTemplate();" title="Download Template" >Download</button> <%--<asp:Button ID="Button1" runat="server" Text="Download" ToolTip="Download the proper template." onclick="BtnTemplate_Click" /> --%> <br /><br /> 2. Select the file: <telerik:RadUpload ID="RadUpload" runat="server" Skin="Outlook" AllowedFileExtensions="csv" /> <asp:CustomValidator ID="CustomValidator1" runat="server" CssClass="errorLabel" ErrorMessage="Please select at least one CSV file." OnServerValidate="CustomValidator1_ServerValidate"> </asp:CustomValidator> <br /> 3. Submit your file: <br /> <asp:Button ID="BtnSumbit" runat="server" Text="Import" ToolTip="Import advisors into APP system." onclick="BtnSumbit_Click" Width="150px" /> </div> </div> </div> <br /> <div class="errorLabel"> <asp:Image ID="SuccessImg" runat="server" ImageUrl="../Images/success.gif" Visible="false" /> <asp:Image ID="ErrorImg" runat="server" ImageUrl="../Images/error.gif" Visible="false" /> <asp:Label ID="OutputLabel" ForeColor="Red" runat="server" Visible="false" /> </div> <div class="details" > <asp:Label ID="lblReport" runat="server" /> </div> </telerik:RadPageView> </telerik:RadMultiPage></asp:Content><telerik:AjaxSetting AjaxControlID="MatCompAddComponentButton"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="PanelMatComp" UpdatePanelCssClass="" /> </UpdatedControls></telerik:AjaxSetting><asp:Panel ID="PanelMatComp" runat="server" Visible="false"> <telerik:OpenAccessDataSource ID="OpenAccessDataSourceItems" runat="server" ObjectContextProvider="idee5.DispatcherModel.DispatcherEntities, idee5.DispatcherModel" TypeName="idee5.DispatcherModel.Item" Where="this.MasterSystemHierarchy == @MasterSystemHierarchy"> <WhereParameters> <asp:QueryStringParameter Name="MasterSystemHierarchy" QueryStringField="Hierarchy" /> </WhereParameters> </telerik:OpenAccessDataSource> <asp:CheckBox ID="MatCompComplete" runat="server" Enabled="False" Text="Komplettentnahme" /> <telerik:RadComboBox ID="MatCompItemComboBox" Runat="server" Culture="de-DE" DataSourceID="OpenAccessDataSourceItems" DataTextField="Label" DataValueField="Id" EmptyMessage="Bitte Artikel auswählen" EnableAutomaticLoadOnDemand="True" ItemsPerRequest="10" Label="Artikel" LoadingMessage="Lade..." AutoPostBack="True" ShowMoreResultsBox="True" EnableVirtualScrolling="True" Filter="Contains" Height="180px" Width="250px" CausesValidation="False" EnableItemCaching="True"> </telerik:RadComboBox>...</asp:Panel>a.RadComboBoxItemDataBoundEventArgs.registerClass("Telerik.Web.UI.RadComboBoxItemDataBoundEventArgs",a.RadComboBoxItemEventArgs);})();(function(){var a=$telerik.$;var b=Telerik.Web.UI;a.registerEnum(b,"Keys",{Tab:9,Enter:13,Shift:16,Escape:27,Space:32,PageUp:33,PageDown:34,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Insert:45,Del:46,Zero:48,Numpad0:96,Numpad9:105,F1:112,F12:123,Delete:127});a.registerEnum(b,"RadComboBoxFilter",{None:0,Contains:1,StartsWith:2});a.registerEnum(b,"RadComboBoxExpandDirection",{Up:1,Down:2});a.registerEnum(b,"RadComboBoxCheckedItemsTexts",{FitInInput:0,DisplayAllInInput:1});a.registerEnum(b,"RadComboBoxDropDownAutoWidth",{Disabled:0,Enabled:1});})();$telerik.findComboBox=$fiServer Error in '/' Application. FieldEditors collection is empty. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: FieldEditors collection is empty. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [NullReferenceException: FieldEditors collection is empty.] Telerik.Web.UI.RadFilterDataFieldEditorCollection.System.Collections.Generic.IList<Telerik.Web.UI.RadFilterDataFieldEditor>.get_Item(Int32 index) +156 Telerik.Web.UI.RadFilter.AddChildExpression(RadFilterGroupExpressionItem groupItem, Boolean isGroup) +118 Telerik.Web.UI.RadFilterCommandEventArgs.ExecuteCommand(Object source) +173 Telerik.Web.UI.RadFilter.OnBubbleEvent(Object source, EventArgs args) +185 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +70 Telerik.Web.UI.RadFilterExpressionItem.OnBubbleEvent(Object source, EventArgs args) +131 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +70 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981protected void Page_Load(object sender, EventArgs e){ if (string.IsNullOrEmpty(this.FilterType)) throw new NullReferenceException("FilterType must not be undefined."); var instance = Activator.CreateInstance("MyDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=123456789", "MyDLL.Data.Biz.MetaData." + this.FilterType); PropertyInfo[] properties = instance.GetType().GetProperties( BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo p in properties) { RadFilterDataFieldEditor f = null; if (p.PropertyType == typeof(int)) { f = new RadFilterNumericFieldEditor(); } if (p.PropertyType == typeof(bool)) { f = new RadFilterBooleanFieldEditor(); } if (p.PropertyType == typeof(DateTime)) { f = new RadFilterDateFieldEditor(); } if (p.PropertyType == typeof(string)) { f = new RadFilterTextFieldEditor(); } if (f != null) { filter.FieldEditors.Add(f); } if (!Page.IsPostBack) { if (p.PropertyType == typeof(int)) { f.DisplayName = p.Name.HumanizeString(); f.DataType = typeof(int); f.FieldName = p.Name; f.ToolTip = p.Name; } if (p.PropertyType == typeof(bool)) { f.DisplayName = p.Name.HumanizeString(); f.DataType = typeof(bool); f.FieldName = p.Name; f.ToolTip = p.Name; } if (p.PropertyType == typeof(DateTime)) { f.DisplayName = p.Name.HumanizeString(); f.DataType = typeof(DateTime); f.FieldName = p.Name; f.ToolTip = p.Name; } if (p.PropertyType == typeof(string)) { f.DisplayName = p.Name.HumanizeString(); f.DataType = typeof(string); f.FieldName = p.Name; f.ToolTip = p.Name; } } }}Hi
I have a RadListView bound to an EntityDataSource. Within the ItemTemplate I then have a RadButton with a ContentTemplate.
The RadButton is defined as follows (within the ListView ItemTemplate):
<telerik:RadButton ID="VehicleRadButton" runat="server" ButtonType="StandardButton"
AutoPostBack="true" GroupName="radVehicle" CommandName="Select"
ToggleType="Radio" Text='<%# String.Format("{0}", Eval("f1")) %>'>
<ContentTemplate>
<%# String.Format("[{0}]", Eval("f2")) %>
</ContentTemplate>
</telerik:RadButton>
When I do this an error occurs:
Unable to cast object of type 'Telerik.Web.UI.RadButton' to type 'Telerik.Web.UI.RibbonBarTemplateItem'.
Is it possible to do this?
Thanks
Tony
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="dgv"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="dgv" /> <telerik:AjaxUpdatedControl ControlID="lblStatus" /> <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager><telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Silk" /><div class="dbStatus"> <asp:Label runat="server" ID="lblStatus" EnableViewState="false" Font-Bold="true" /></div><telerik:RadGrid ID="dgv" runat="server" AutoGenerateColumns="False" PageSize="10" AllowPaging="True" AllowSorting="True" OnNeedDataSource="dgv_NeedDataSource" OnUpdateCommand="dgv_UpdateCommand" OnInsertCommand="dgv_InsertCommand" OnDeleteCommand="dgv_DeleteCommand" OnItemInserted="dgv_ItemInserted"> <MasterTableView TableLayout="Auto" DataKeyNames="Record_Id" ShowHeadersWhenNoRecords="true" EditMode="PopUp"> <NoRecordsTemplate> <div> There are no records </div> </NoRecordsTemplate> <Columns> <telerik:GridBoundColumn UniqueName="colRecordId" DataField="Record_Id" DataType="System.Int64" HeaderText="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,CountryId%>"> <%--<HeaderStyle Width="120" />--%> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="colContinent" DataField="Continent" DataType="System.String" HeaderText="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,Continent%>"> <%--<HeaderStyle Width="160" />--%> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="colContinentBI" DataField="ContinentBI" DataType="System.String" HeaderText="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,ContinentBI%>"> <%--<HeaderStyle Width="160" />--%> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="colDescription" DataField="Description" DataType="System.String" HeaderText="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,Description%>"> <%--<HeaderStyle Width="200" />--%> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="colDescriptionBI" DataField="DescriptionBI" DataType="System.String" HeaderText="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,DescriptionBI%>"> <%--<HeaderStyle Width="200" />--%> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="colCreatedBy" DataField="CreatedBy" DataType="System.String" HeaderText="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,CreatedBy%>"> <%--<HeaderStyle Width="120" />--%> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="colCreatedON" DataField="CreatedOn" DataType="System.DateTime" HeaderText="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,CreatedDate%>"> <%--<HeaderStyle Width="160" />--%> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="colModifiedBy" DataField="ModifiedBy" DataType="System.String" HeaderText="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,ModifiedBy%>"> <%--<HeaderStyle Width="120" />--%> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="colModifiedOn" DataField="ModifiedOn" DataType="System.DateTime" HeaderText="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,ModifiedDate%>"> <%--<HeaderStyle Width="160" />--%> </telerik:GridBoundColumn> </Columns> <EditFormSettings EditFormType="Template" PopUpSettings-Modal="true"> <FormTemplate> <table> <tr> <td colspan="3"> <br /> <asp:Label runat="server" ID="lblStatus" Font-Bold="true" /> <br /> </td> </tr> <tr> <td class="tdLabel"> <asp:Label runat="server" ID="lblCountryId" Text="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,CountryId%>" AssociatedControlID="txtCountryId" /> </td> <td class="tdControl"> <telerik:RadTextBox ID="txtCountryId" runat="server" Width="300" ReadOnly="true" Text='<%# Bind("Record_Id") %>' /> </td> <td></td> </tr> <tr> <td class="tdLabel"> <asp:Label runat="server" ID="lblContinent" Text="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,Continent%>" AssociatedControlID="txtContinent" /> </td> <td class="tdControl"> <telerik:RadTextBox ID="txtContinent" runat="server" Width="300" MaxLength="255" Text='<%# Bind("Continent") %>' /> </td> <td></td> </tr> <tr> <td class="tdLabel"> <asp:Label runat="server" ID="lblContinentBI" Text="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,ContinentBI%>" AssociatedControlID="txtContinentBI" /> </td> <td class="tdControl"> <telerik:RadTextBox ID="txtContinentBI" runat="server" Width="300" MaxLength="255" Text='<%# Bind("ContinentBI") %>' /> </td> <td></td> </tr> <tr> <td class="tdLabel"> <asp:Label runat="server" ID="lblDescription" Text="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,Description%>" AssociatedControlID="txtDescription" /> </td> <td class="tdControl"> <telerik:RadTextBox ID="txtDescription" runat="server" Width="300" MaxLength="255" ValidationGroup="CountryValidation" Wrap="false" EmptyMessage="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,Description%>" Text='<%# Bind("Description") %>' /> </td> <td> <asp:RequiredFieldValidator ID="rfvDescription" runat="server" ValidationGroup="CountryValidation" ControlToValidate="txtDescription" ErrorMessage="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,DescriptionRequiredValidationMessage%>" Text="*" /> </td> </tr> <tr> <td class="tdLabel"> <asp:Label runat="server" ID="Label1" Text="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,DescriptionBI%>" AssociatedControlID="txtDescriptionBI" /> </td> <td class="tdControl"> <telerik:RadTextBox ID="txtDescriptionBI" runat="server" Width="300" MaxLength="255" ValidationGroup="CountryValidation" Wrap="False" EmptyMessage="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,DescriptionBI%>" Text='<%# Bind("DescriptionBI") %>' /> </td> <td> <asp:RequiredFieldValidator ID="rfvDescriptionBI" runat="server" ValidationGroup="CountryValidation" ControlToValidate="txtDescriptionBI" ErrorMessage="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,DescriptionBIRequiredValidationMessage%>" Text="*" /> </td> </tr> </table> <br /> <br /> <table> <tr> <td class="tdButton"> <telerik:RadButton ID="btnSubmit" runat="server" Width="100%" ValidationGroup="CountryValidation" Text="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,Submit%>" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' /> </td> <td class="tdButton"> <telerik:RadButton ID="btnCancel" runat="server" Width="100%" Text="<%$Resources:AM.BLIS.SP.Common.Resources.BLISResource,Cancel%>" CommandName="Delete" /> </td> </tr> </table> </FormTemplate> </EditFormSettings> </MasterTableView></telerik:RadGrid><telerik:RadWindowManager ID="RadWindowManager1" runat="server" />CountryMasterBPO cm = new CountryMasterBPO();protected void dgv_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e){ this.dgv.DataSource = cm.GetAllCountries();}protected void dgv_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e){ RadAjaxManager1.ResponseScripts.Add(string.Format("Insert Command")); var editableItem = ((GridEditableItem)e.Item); var newCountry = new tbCountry_Master(); Hashtable values = new Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(values, editableItem); newCountry.Continent = (string)values["Continent"]; newCountry.ContinentBI = (string)values["ContinentBI"]; newCountry.Description = (string)values["Description"]; newCountry.DescriptionBI = (string)values["DescriptionBI"]; newCountry.Exp1 = "0"; newCountry.Exp2 = "0"; newCountry.CreatedBy = SPContext.Current.Web.CurrentUser.LoginName; newCountry.CreatedOn = DateTime.Now; newCountry.ModifiedBy = SPContext.Current.Web.CurrentUser.LoginName; newCountry.ModifiedOn = DateTime.Now; var result = cm.SaveCountry(newCountry); DisplayMessage(!result, result ? "Sucessfully Saved" : "Error!!! Try Again");}protected void dgv_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e){ RadAjaxManager1.ResponseScripts.Add(string.Format("Update Command")); var editableItem = ((GridEditableItem)e.Item); var recordId = (long)editableItem.GetDataKeyValue("Record_Id"); RadAjaxManager1.ResponseScripts.Add(string.Format("Record Id: {0}", recordId)); var country = cm.GetCountry(recordId); if (country != null) { RadAjaxManager1.ResponseScripts.Add(string.Format("Description: {0}", country.Description)); editableItem.UpdateValues(country); country.ModifiedBy = SPContext.Current.Web.CurrentUser.LoginName; country.ModifiedOn = DateTime.Now; var result = cm.SaveCountry(country); DisplayMessage(!result, result ? "Sucessfully Updated" : "Error!!! Try Again"); }}protected void dgv_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e){ RadAjaxManager1.ResponseScripts.Add(string.Format("Delete Command")); var editableItem = ((GridEditableItem)e.Item); var recordId = (long)editableItem.GetDataKeyValue("Record_Id"); bool isReferenced = false; var result = cm.DeleteCountry(recordId, out isReferenced); DisplayMessage(!result, result ? "Sucessfully Deleted" : "Error!!! Try Again");}protected void dgv_ItemInserted(object sender, GridInsertedEventArgs e){ if (e.Exception != null) { e.ExceptionHandled = true; e.KeepInInsertMode = true; DisplayMessage(true, e.Exception.Message.ToString()); }}private void DisplayMessage(bool isError, string text){ this.lblStatus.ForeColor = (isError) ? Color.Red : Color.Green; this.lblStatus.Text = text;}