This is a migrated thread and some comments may be shown as answers.

Column and Footer of Rag grid missing on Postback

3 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aman
Top achievements
Rank 1
Aman asked on 16 Jan 2015, 12:59 PM
Hi Greetings,

We have a Rad Grid with Update and Cancel button as part of the first column, during the first post back this column along with the footer of the grid is not displayed. However in the subsequent postback the same column along with the footer is displayed. I have attached the image of the grid before and after the first post back for reference. Also i have pasted the code of the form below:

<asp:Content ID="Content1" ContentPlaceHolderID="cphCMS" runat="server">
    <link href="../StyleSheets/CMS4.0StyleSheet.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">
        var isHelpPopup = false;
        function openwindow() {
            isHelpPopup = true;
            window.open("../MaintenanceScreens/HelpPopup.aspx?FormName=" + "FMEAv2.aspx", "_blank", "toolbar=no, scrollbars=no, resizable=no, Right=0, width=735px, height=615px");
        }
    </script>
    <style type="text/css">
        #txtRelevantrisk_Edit .reLayoutWrapper, .reWrapper_corner, .reWrapper_center, .reLeftVerticalSide, .reRightVerticalSide, .reTlbVertical, .reToolCell, .reContentCell, .reToolZone, .reBottomTable, .reEditorModesCell, .reBottomZone, .reResizeCell
        {
            border: 0 none !important;
            padding: 0 !important;
        }
        #txtRelevantrisk_Edit .Telerik.reWrapper, .Telerik.RadEditor .reContentCell, .Telerik.reColorPicker, .Telerik.reInsertTable, .Telerik.reCustomLinks a:hover
        {
            border: 1px solid #828282 !important;
        }
        #txtRelevantrisk_Edit .reLeftVerticalSide, .reRightVerticalSide
        {
            padding: 2px !important;
        }
    </style>
    <table width="98%" cellpadding="0" cellspacing="0" border="0" style="padding-left: 10px">
        <tr style="vertical-align: top;">
            <td class="label" style="width: 10%; padding-left: 10px">
                FMEA
            </td>
            <td align="center">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:Label ID="lblMessage" CssClass="gridlabel" runat="server"></asp:Label></ContentTemplate>
                </asp:UpdatePanel>
            </td>
            <td align="right" style="width: 10%; padding-right: 20px">
                <asp:Button ID="btnSave" Visible="false" runat="server" Text="Save" ValidationGroup="Save"
                    CausesValidation="true" OnClick="btnSave_Click" />
            </td>
        </tr>
        <tr>
            <td style="padding-left: 10px">
                <asp:ImageButton ID="imgHelp" ImageUrl="~/Images/Help.png" runat="server" OnClientClick="openwindow(); return false;" />
            </td>
            <td align="right" valign="top" style="padding-right: 10px" colspan="2">
                <span id="spnAsterik" runat="server" style="color: Red;">*</span><em> </em><span
                    id="spnCurrentIsrequired" runat="server" style="padding-right: 10px"><em>indicates required</em></span>
            </td>
        </tr>
        <tr>
            <td>
                <br />
            </td>
        </tr>
        <tr>
            <td align="left" valign="top" class="label" colspan="3">
                FMEA <span id="spnCurrentIsControlPlan" class="label" runat="server" style="color: Red;">
                    *</span>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <telerik:radajaxmanager id="radManagerFMEAv2" runat="server">
                </telerik:radajaxmanager>
                <telerik:radajaxmanagerproxy id="RadAjaxManagerFMEAv2" runat="server">
                    <ajaxsettings>
                        <telerik:AjaxSetting AjaxControlID="grdFMEAv2">
                            <UpdatedControls>
                                <telerik:AjaxUpdatedControl ControlID="grdFMEAv2" UpdatePanelRenderMode="Inline"
                                    LoadingPanelID="ra1grdRAQ" />
                            </UpdatedControls>
                        </telerik:AjaxSetting>
                    </ajaxsettings>
                </telerik:radajaxmanagerproxy>
                <telerik:radgrid id="grdFMEAv2" runat="server" autogeneratecolumns="false" onneeddatasource="grdFMEA_NeedDataSource"
                    onitemdatabound="grdFMEA_OnItemDataBound" oninsertcommand="grdFMEA_InsertCommand"
                    ondeletecommand="grdFMEA_DeleteCommand" onitemcommand="grdFMEA_ItemCommand" onitemcreated="grdFMEA_ItemCreated"
                    width="98%" allowpaging="true" pagerstyle-alwaysvisible="true" allowsorting="true" >
                    <mastertableview commanditemdisplay="Bottom" editmode="InPlace" allowsorting="true"
                        datakeynames="CMSFMEAID">
                        <Columns>
                            <telerik:GridEditCommandColumn UniqueName="Edit" UpdateText="Update" ButtonType="ImageButton"
                                CancelImageUrl="../Images/Cancel.gif" InsertImageUrl="../Images/Update.gif" UpdateImageUrl="../Images/Update.gif"
                                EditImageUrl="../Images/Edit.gif">
                                <ItemStyle HorizontalAlign="center" Width="5%"></ItemStyle>
                            </telerik:GridEditCommandColumn>
                            <telerik:GridTemplateColumn HeaderText="FMEA Type" UniqueName="FMEAType" DataField="FMEAType"
                                SortExpression="FMEAType" HeaderStyle-Width="12%" HeaderStyle-HorizontalAlign="Left">
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="lblFMEAType" CssClass="gridlabel" Text='<%#Eval("FMEAType")%>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadComboBox ID="rcbFMEATypeEdit" runat="server" DataTextField="FMEAType"
                                        Width="80px" AutoPostBack="true" OnSelectedIndexChanged="rcbFMEATypeEdit_SelectedIndexChanged"
                                        CssClass="normalDropDownList" Skin="Web20" MarkFirstMatch="true">
                                        <Items>
                                            <telerik:RadComboBoxItem runat="server" Text="" Value="" />
                                            <telerik:RadComboBoxItem runat="server" Text="DFMEA" Value="1" />
                                            <telerik:RadComboBoxItem runat="server" Text="PFMEA" Value="2" />
                                            <telerik:RadComboBoxItem runat="server" Text="No FMEA" Value="3" />
                                        </Items>
                                    </telerik:RadComboBox>
                                    <asp:RequiredFieldValidator ID="rfvFMEAType" runat="server" ControlToValidate="rcbFMEATypeEdit"
                                       Display="None" SetFocusOnError="true" ErrorMessage="Please select FMEA Type"
                                       ></asp:RequiredFieldValidator>
                                    <ajaxToolkit:ValidatorCalloutExtender ID="vceFMEAType" runat="server" TargetControlID="rfvFMEAType"
                                    CssClass="AjaxValidatorCalloutExtender">
                                    </ajaxToolkit:ValidatorCalloutExtender>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Left" Width="12%" VerticalAlign="Top"></ItemStyle>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="FMEA Name" ItemStyle-HorizontalAlign="Left"
                                SortExpression="FMEAName" HeaderStyle-Width="12%">
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="lblFMEAName" CssClass="gridlabel" Text='<%#Eval("FMEAName")%>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadComboBox ID="rcbFMEANameEdit" runat="server" DataTextField="FMEAName"
                                        Width="80px" AutoPostBack="true" OnSelectedIndexChanged="rcbFMEANameEdit_SelectedIndexChanged"
                                        CssClass="normalDropDownList" Skin="Web20" MarkFirstMatch="true">
                                    </telerik:RadComboBox>
                                    <asp:RequiredFieldValidator ID="rfvFMEANameEdit" runat="server" ControlToValidate="rcbFMEANameEdit"
                                        ErrorMessage="Please select FMEA Name" Display="None" InitialValue=""></asp:RequiredFieldValidator>
                                    <ajaxToolkit:ValidatorCalloutExtender ID="vceFMEAName" runat="server" TargetControlID="rfvFMEANameEdit"
                                    CssClass="AjaxValidatorCalloutExtender">
                                    </ajaxToolkit:ValidatorCalloutExtender>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Left" Width="10%" VerticalAlign="Top"></ItemStyle>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="FMEA Owner" DataField="FMEA Owner" ItemStyle-HorizontalAlign="Left"
                                SortExpression="FMEAOwnerName" HeaderStyle-Width="12%">
                                <ItemTemplate>
                                    <asp:Label ID="lblFMEAOwner" runat="server" CssClass="gridlabel" Text='<%#Eval("FMEAOwnerName")%>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:Label ID="lblFMEAOwnerEdit" runat="server" CssClass="gridlabel" Text='<%#Eval("FMEAOwnerName")%>'></asp:Label>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Left" Width="10%" VerticalAlign="Top"></ItemStyle>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Relevant Risk(s)" DataField="Relevant Risk(s)"
                                ItemStyle-HorizontalAlign="Left" SortExpression="RelevantRisk" HeaderStyle-Width="20%">
                                <ItemTemplate>
                                    <div id="txtRelevantrisk" runat="server">
                                        <%#Eval("RelevantRisk")%>
                                    </div>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadEditor ID="txtRelevantrisk_Edit" runat="server" Font-Names="Arial" Font-Size="10pt"
                                        Content='<%#Eval("RelevantRisk")%>' EditModes="Design" Height="200px" Width="280px" 
                                        ContentFilters="IndentHTMLContent">
                                        <CssFiles>
                                            <telerik:EditorCssFile Value="~/EditorContentArea.css" />
                                        </CssFiles>
                                        <RealFontSizes>
                                            <telerik:EditorRealFontSize Value="8pt" />
                                            <telerik:EditorRealFontSize Value="9pt" />
                                            <telerik:EditorRealFontSize Value="10pt" />
                                            <telerik:EditorRealFontSize Value="11pt" />
                                            <telerik:EditorRealFontSize Value="12pt" />
                                            <telerik:EditorRealFontSize Value="14pt" />
                                            <telerik:EditorRealFontSize Value="16pt" />
                                            <telerik:EditorRealFontSize Value="18pt" />
                                            <telerik:EditorRealFontSize Value="20pt" />
                                            <telerik:EditorRealFontSize Value="22pt" />
                                            <telerik:EditorRealFontSize Value="24pt" />
                                            <telerik:EditorRealFontSize Value="26pt" />
                                            <telerik:EditorRealFontSize Value="28pt" />
                                            <telerik:EditorRealFontSize Value="32pt" />
                                            <telerik:EditorRealFontSize Value="36pt" />
                                            <telerik:EditorRealFontSize Value="48pt" />
                                            <telerik:EditorRealFontSize Value="72pt" />
                                        </RealFontSizes>
                                        <Tools>
                                            <telerik:EditorToolGroup>
                                                <telerik:EditorTool Name="Copy" />
                                                <telerik:EditorTool Name="Paste" />
                                                <telerik:EditorTool Name="Bold" />
                                                <telerik:EditorTool Name="FontName" Text="Calibri" />
                                                <telerik:EditorTool Name="RealFontSize" Text="12pt" />
                                                <telerik:EditorTool Name="InsertOrderedList" />
                                                <telerik:EditorTool Name="InsertUnorderedList" />
                                            </telerik:EditorToolGroup>
                                        </Tools>
                                        <FontNames>
                                            <telerik:EditorFont Value="Arial" />
                                            <telerik:EditorFont Value="Arial Black" />
                                            <telerik:EditorFont Value="Arial Narrow" />
                                            <telerik:EditorFont Value="Calibri" />
                                            <telerik:EditorFont Value="Comic Sans MS" />
                                            <telerik:EditorFont Value="Courier New" />
                                            <telerik:EditorFont Value="Georgia" />
                                            <telerik:EditorFont Value="Lucida Console" />
                                            <telerik:EditorFont Value="sans-serif" />
                                            <telerik:EditorFont Value="Tahoma" />
                                            <telerik:EditorFont Value="Times New Roman" />
                                            <telerik:EditorFont Value="Verdana" />
                                        </FontNames>
                                        <Content></Content>
                                    </telerik:RadEditor>
                                    <asp:RequiredFieldValidator ID="rfvRelevantrisk_Edit" runat="server" ControlToValidate="txtRelevantrisk_Edit"
                                        ErrorMessage="Please Enter Relevant Risk(s)" Display="None" InitialValue=""></asp:RequiredFieldValidator>
                                    <ajaxToolkit:ValidatorCalloutExtender ID="vceRelevantrisk" runat="server" TargetControlID="rfvRelevantrisk_Edit"
                                    CssClass="AjaxValidatorCalloutExtender">
                                    </ajaxToolkit:ValidatorCalloutExtender>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Left" Width="20%" VerticalAlign="Top"></ItemStyle>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Mitigation Item(s)" DataField="Mitigation Item(s)"
                                ItemStyle-HorizontalAlign="Left" SortExpression="MitigationAction" HeaderStyle-Width="20%">
                                <ItemTemplate>
                                    <div id="txtMT" runat="server">
                                        <%#Eval("MitigationAction")%>
                                    </div>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadEditor ID="txtMTEdit" runat="server" Font-Names="Arial" Font-Size="10pt"
                                        Content='<%#Eval("MitigationAction")%>' EditModes="Design" Height="200px" Width="280px"
                                        ContentFilters="IndentHTMLContent">
                                        <CssFiles>
                                            <telerik:EditorCssFile Value="~/EditorContentArea.css" />
                                        </CssFiles>
                                        <RealFontSizes>
                                            <telerik:EditorRealFontSize Value="8pt" />
                                            <telerik:EditorRealFontSize Value="9pt" />
                                            <telerik:EditorRealFontSize Value="10pt" />
                                            <telerik:EditorRealFontSize Value="11pt" />
                                            <telerik:EditorRealFontSize Value="12pt" />
                                            <telerik:EditorRealFontSize Value="14pt" />
                                            <telerik:EditorRealFontSize Value="16pt" />
                                            <telerik:EditorRealFontSize Value="18pt" />
                                            <telerik:EditorRealFontSize Value="20pt" />
                                            <telerik:EditorRealFontSize Value="22pt" />
                                            <telerik:EditorRealFontSize Value="24pt" />
                                            <telerik:EditorRealFontSize Value="26pt" />
                                            <telerik:EditorRealFontSize Value="28pt" />
                                            <telerik:EditorRealFontSize Value="32pt" />
                                            <telerik:EditorRealFontSize Value="36pt" />
                                            <telerik:EditorRealFontSize Value="48pt" />
                                            <telerik:EditorRealFontSize Value="72pt" />
                                        </RealFontSizes>
                                        <Tools>
                                            <telerik:EditorToolGroup>
                                                <telerik:EditorTool Name="Copy" />
                                                <telerik:EditorTool Name="Paste" />
                                                <telerik:EditorTool Name="Bold" />
                                                <telerik:EditorTool Name="FontName" Text="Calibri" />
                                                <telerik:EditorTool Name="RealFontSize" Text="12pt" />
                                                <telerik:EditorTool Name="InsertOrderedList" />
                                                <telerik:EditorTool Name="InsertUnorderedList" />
                                            </telerik:EditorToolGroup>
                                        </Tools>
                                        <FontNames>
                                            <telerik:EditorFont Value="Arial" />
                                            <telerik:EditorFont Value="Arial Black" />
                                            <telerik:EditorFont Value="Arial Narrow" />
                                            <telerik:EditorFont Value="Calibri" />
                                            <telerik:EditorFont Value="Comic Sans MS" />
                                            <telerik:EditorFont Value="Courier New" />
                                            <telerik:EditorFont Value="Georgia" />
                                            <telerik:EditorFont Value="Lucida Console" />
                                            <telerik:EditorFont Value="sans-serif" />
                                            <telerik:EditorFont Value="Tahoma" />
                                            <telerik:EditorFont Value="Times New Roman" />
                                            <telerik:EditorFont Value="Verdana" />
                                        </FontNames>
                                        <Content></Content>
                                    </telerik:RadEditor>
                                    <asp:RequiredFieldValidator ID="rfvMitigationAction" runat="server" ControlToValidate="txtMTEdit"
                                        ErrorMessage="Please Enter Mitigation Action(s)" Display="None" InitialValue=""></asp:RequiredFieldValidator>
                                    <ajaxToolkit:ValidatorCalloutExtender ID="vceMT" runat="server" TargetControlID="rfvMitigationAction"
                                    CssClass="AjaxValidatorCalloutExtender">
                                    </ajaxToolkit:ValidatorCalloutExtender>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Left" Width="20%" VerticalAlign="Top"></ItemStyle>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="URL" DataField="URL" ItemStyle-HorizontalAlign="Left"
                                HeaderStyle-Width="10%">
                                <ItemTemplate>
                                    <asp:HyperLink ID="hplnkURL" runat="server" Text="View FMEA here" NavigateUrl='<%#Eval("URL")%>'
                                        Target="_blank" ForeColor="Blue"></asp:HyperLink>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox runat="server" ID="txtURL" Text='<%#Eval("URL")%>' CssClass="textboxCalibri"></asp:TextBox>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Left" Width="15%"></ItemStyle>
                            </telerik:GridTemplateColumn>
                            <telerik:GridButtonColumn UniqueName="Delete" CommandName="Delete" ButtonType="ImageButton"
                                ImageUrl="..\Images\delete.gif" ConfirmText="Do you want to delete this row?">
                                <ItemStyle HorizontalAlign="Left" Width="4%"></ItemStyle>
                            </telerik:GridButtonColumn>
                        </Columns>
                        <ItemStyle VerticalAlign="Top" />
                        <ItemStyle CssClass="gridlabel" VerticalAlign="Top" />
                        <AlternatingItemStyle CssClass="gridlabel" VerticalAlign="Top" />
                        <HeaderStyle CssClass="gridlabel" />
                        <CommandItemSettings RefreshText="" ShowRefreshButton="false" AddNewRecordImageUrl="../Images/AddRecord.gif" />
                        <NoRecordsTemplate>
                            No Records to display.</NoRecordsTemplate>
                    </mastertableview>
                </telerik:radgrid>
                <telerik:radajaxloadingpanel id="ra1grdRAQ" runat="server" horizontalalign="Center"
                    enableskintransparency="true" skin="Default" backgroundposition="Center">
                </telerik:radajaxloadingpanel>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="left" valign="top" class="label" colspan="3">
                FMEA Attachment <span id="spnFMEAv2" visible="false" class="label" runat="server"
                    style="color: Red;">*</span>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <uc:multipleattachments id="MultipleAttachments" runat="server" documenttype="FMEAv2" />
            </td>
        </tr>
        <tr>
            <td align="left">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="left">
                &nbsp;
            </td>
        </tr>
    </table>
</asp:Content>

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 21 Jan 2015, 08:41 AM
Hi Aman,

The missing items from the grid is commonly observed when there is a databinding issue. I noticed that you are binding the grid through NeedDataSource event handler but can you confirm that you are not calling DataBind() method anywhere in your code behind? I would appreciate if you can provide your code behind as well in order to investigate the issue further.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Aman
Top achievements
Rank 1
answered on 21 Jan 2015, 04:03 PM
Hi Kostadin,

Thanks for your valuable inputs, I checked the code behind for DataBind() and I dint find it being used with respect to the grid in which the problem occurs. I have provided the code behind events with respect to grid below for reference:

 /// <summary>
        /// 
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void grdFMEA_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {


            objSolutionDevelopmentBLL = new SolutionDevelopmentBLL();
            objCommonMethods = new CommonMethods();
            try
            {
                DataTable dtFMEAv2 = new DataTable();
                dtFMEAv2 = objSolutionDevelopmentBLL.getTransactionalFMEAv2(cmsProjectNumber, cmsStageId, "0");
                if (dtFMEAv2.Rows.Count > CommonConstantVariables.PAGESIZE_VALUE)
                {
                    grdFMEAv2.PagerStyle.AlwaysVisible = true;

                }
                else
                {
                    grdFMEAv2.PagerStyle.AlwaysVisible = false;
                }
                grdFMEAv2.DataSource = dtFMEAv2;
            }
            catch (Exception ex)
            {
                objCommonMethods.DisplayMessage(this.lblMessage, "Error", "Error occurred while binding FMEA data.");
                objCommonMethods.GenericExceptionMethod(ex);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdFMEA_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            try
            {
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    GridEditableItem edititem = (GridEditableItem)e.Item;

                    RadComboBox rcbFMEATypeEdit = edititem.FindControl("rcbFMEATypeEdit") as RadComboBox;
                    RadComboBox rcbFMEANameEdit = edititem.FindControl("rcbFMEANameEdit") as RadComboBox;
                    RequiredFieldValidator rfvFMEANameEdit = (RequiredFieldValidator)edititem.FindControl("rfvFMEANameEdit");

                    if (!(e.Item is IGridInsertItem))   // Rad Grid Edit Mode
                    {
                        rcbFMEATypeEdit.Items.FindItemByValue(Convert.ToString(((DataRowView)e.Item.DataItem)["FMEATypeID"]).Trim()).Selected = true;

                        DataSet dsFMEAName = new DataSet();

                        if (rcbFMEATypeEdit.SelectedItem.Text != string.Empty)
                        {
                            dsFMEAName = objFMEAMaintenanceBLL.GetFMEANameByType(businessUnit, rcbFMEATypeEdit.SelectedItem.Text.Trim());
                            foreach (DataRow dr in dsFMEAName.Tables[0].Rows)
                            {
                                dr["FMEAName"] = dr["FMEAName"].ToString().Trim();
                            }
                            rcbFMEANameEdit.DataTextField = "FMEAName";
                            rcbFMEANameEdit.DataValueField = "FMEAOwnerGUID";
                            rcbFMEANameEdit.DataSource = dsFMEAName;
                            rcbFMEANameEdit.DataBind();
                            rcbFMEANameEdit.Items.Insert(0, new RadComboBoxItem(string.Empty, string.Empty));

                            rcbFMEANameEdit.Items.FindItemByText(Convert.ToString(((DataRowView)e.Item.DataItem)["FMEAName"]).Trim()).Selected = true;

                        }
                        else
                        {
                            rcbFMEANameEdit.DataTextField = "FMEAName";
                            rcbFMEANameEdit.DataValueField = "FMEAOwnerGUID";
                            rcbFMEANameEdit.DataSource = null;
                            rcbFMEANameEdit.DataBind();
                            rcbFMEANameEdit.Items.Insert(0, new RadComboBoxItem(string.Empty, string.Empty));

                        }

                        if (rcbFMEATypeEdit.SelectedItem.Text == "No FMEA")
                        {
                            rfvFMEANameEdit.Enabled = false;
                        }
                        else
                        {
                            rfvFMEANameEdit.Enabled = true;
                        }

                    }

                }
                else
                {
                    HyperLink hplnkURL = e.Item.FindControl("hplnkURL") as HyperLink;

                    string URL = (((DataRowView)e.Item.DataItem)["URL"]).ToString();
                    if (URL == null || URL == string.Empty)
                    {
                        hplnkURL.Visible = false;
                    }
                    else
                    {
                        hplnkURL.Visible = true;
                    }

                }
            }
            catch (Exception ex)
            {
                objCommonMethods.GenericExceptionMethod(ex);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void grdFMEA_InsertCommand(object source, GridCommandEventArgs e)
        {
            try
            {
                DataSet dsFMEAName = new DataSet();
                string FMEAOwnerGUID = string.Empty;
                string modifiedBy = string.Empty;
                string actionItemID = string.Empty;
                string sMessage = string.Empty;
                NewProjectRequestBLL objNewProjectRequestBLL = null;
                string loggedinGUID = string.Empty;
                DataTable dtActionItems = null;
                ActionItemsBLL objActionItems = new ActionItemsBLL();
                string assignedToMail = string.Empty;
                string actionItemTab = string.Empty;
                string link = string.Empty;
                string mail = string.Empty;
                ArrayList alOutPutParam = null;

                if (!string.IsNullOrEmpty(session.FQN))
                {
                    objNewProjectRequestBLL = new NewProjectRequestBLL();
                    loggedinGUID = objNewProjectRequestBLL.GetEmployeeGUID(session.FQN);
                    modifiedBy = session.FullName;

                    GridDataItem dataItem = (GridDataItem)e.Item;
                    string FMEAType = (dataItem.FindControl("rcbFMEATypeEdit") as RadComboBox).SelectedValue.Trim();
                    string FMEATypeName = (dataItem.FindControl("rcbFMEATypeEdit") as RadComboBox).Text.Trim();
                    string FMEAName = (dataItem.FindControl("rcbFMEANameEdit") as RadComboBox).Text.Trim();

                    dsFMEAName = objFMEAMaintenanceBLL.GetFMEANameByType(businessUnit, FMEATypeName);
                    foreach (DataRow dr in dsFMEAName.Tables[0].Rows)
                    {
                        if (dr["FMEAName"].ToString().Trim() == FMEAName)
                        {
                            FMEAOwnerGUID = dr["FMEAOwnerGUID"].ToString().Trim();
                        }
                    }

                    string RelevantRisk = (dataItem.FindControl("txtRelevantrisk_Edit") as RadEditor).Content.Trim();
                    string MitigationItem = (dataItem.FindControl("txtMTEdit") as RadEditor).Content.Trim();
                    string URL = (dataItem.FindControl("txtURL") as TextBox).Text.Trim();
                    string strAction = Convert.ToString(CommonConstantVariables.INSERTACTION_VALUE);

                    alOutPutParam = objFMEAMaintenanceBLL.SetCMSFMEAv2(string.Empty, FMEAName, FMEAType, FMEAOwnerGUID, RelevantRisk, MitigationItem, cmsProjectNumber, cmsStageId, URL, strAction, modifiedBy);
                    actionItemID = alOutPutParam[0].ToString(); //this will give action item id
                    sMessage = alOutPutParam[2].ToString();

                    ///Display the message
                    if (sMessage.Contains("ERROR") || sMessage.Contains("exists"))
                    {
                        objCommonMethods.DisplayMessage(lblMessage, "Error", sMessage);
                    }
                    else
                    {
                        objCommonMethods.DisplayMessage(lblMessage, "Info", sMessage);
                    }


                    //if an action has been created, then Send Action Item Mail
                    if (!string.IsNullOrEmpty(actionItemID))
                    {
                        dtActionItems = objActionItems.GetCMSActionItems(this.cmsProjectNumber, loggedinGUID).Tables[0];
                        DataView dvAssignedTo = dtActionItems.DefaultView;

                        dvAssignedTo.RowFilter = "ActionItemID=" + actionItemID + "";
                        if (dvAssignedTo.ToTable().Rows.Count > 0)
                        {
                            assignedToMail = dvAssignedTo.ToTable().Rows[0]["Email"].ToString();
                        }
                        actionItemTab = Convert.ToString(ConfigurationManager.AppSettings["CMSBundleReviewsite"]) + CommonConstantVariables.CMSDashboardTab + cmsProjectNumber + "&Actionitem=actionitem";


                        link = string.Format(CommonConstantVariables.ACTIONITEM_LINK2, actionItemTab);
                        mail = string.Format(CommonConstantVariables.MAIL_FORMAT, CommonConstantVariables.ACTIONITEM_HEADING, CommonConstantVariables.PROGRAM_NUMBER,
                            cmsProjectNumber, CommonConstantVariables.CHANGE_TITLE, alOutPutParam[1].ToString(), CommonConstantVariables.ACTIONITEM_ID, actionItemID,
                            CommonConstantVariables.ACTION_ITEM, "FMEA " + FMEAName + " risk analysis and all relevant updates completed", link);

                        SendMail(assignedToMail, string.Empty, string.Empty, CommonConstantVariables.SUBJECT_TASKHOLDER, mail + ".");
                    }
                }
            }
            catch (Exception ex)
            {
                objCommonMethods.DisplayMessage(lblMessage, "Error", "Error occurred while adding FMEA data.");
                objCommonMethods.GenericExceptionMethod(ex);
            }


        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void grdFMEA_DeleteCommand(object source, GridCommandEventArgs e)
        {
            try
            {
                string sMessage = string.Empty;
                ArrayList alOutPutParam = null;

                GridDataItem dataItem = (GridDataItem)e.Item;
                alOutPutParam = objFMEAMaintenanceBLL.SetCMSFMEAv2(Convert.ToString(dataItem.GetDataKeyValue("CMSFMEAID")),
                    string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, Convert.ToString(CommonConstantVariables.DELETEACTION_VALUE), string.Empty);


                if (sMessage.Contains("ERROR"))
                {
                    objCommonMethods.DisplayMessage(lblMessage, "Error", sMessage);
                }
                else
                {
                    objCommonMethods.DisplayMessage(lblMessage, "Info", sMessage);
                }

            }
            catch (Exception ex)
            {
                objCommonMethods.DisplayMessage(lblMessage, "Error", "Error occurred while deleting FMEA data.");
                objCommonMethods.GenericExceptionMethod(ex);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void grdFMEA_ItemCommand(object source, GridCommandEventArgs e)
        {
            try
            {
                DataSet dsFMEAName = new DataSet();
                string FMEAOwnerGUID = string.Empty;
                NewProjectRequestBLL objNewProjectRequestBLL = null;
                string loggedinGUID = string.Empty;
                string modifiedBy = string.Empty;
                string actionItemID = string.Empty;
                string sMessage = string.Empty;
                DataTable dtActionItems = null;
                ActionItemsBLL objActionItems = new ActionItemsBLL();
                string assignedToMail = string.Empty;
                string actionItemTab = string.Empty;
                string link = string.Empty;
                string mail = string.Empty;
                ArrayList alOutPutParam = null;

                if (!string.IsNullOrEmpty(session.FQN))
                {
                    objNewProjectRequestBLL = new NewProjectRequestBLL();
                    loggedinGUID = objNewProjectRequestBLL.GetEmployeeGUID(session.FQN);
                    modifiedBy = session.FullName;

                    if (e.CommandName == "Update")
                    {
                        GridDataItem dataItem = (GridDataItem)e.Item;
                        string FMEAType = (dataItem.FindControl("rcbFMEATypeEdit") as RadComboBox).SelectedValue.Trim();
                        string FMEATypeName = (dataItem.FindControl("rcbFMEATypeEdit") as RadComboBox).Text.Trim();
                        string FMEAName = (dataItem.FindControl("rcbFMEANameEdit") as RadComboBox).Text.Trim();

                        dsFMEAName = objFMEAMaintenanceBLL.GetFMEANameByType(businessUnit, FMEATypeName);
                        foreach (DataRow dr in dsFMEAName.Tables[0].Rows)
                        {
                            if (dr["FMEAName"].ToString().Trim() == FMEAName)
                            {
                                FMEAOwnerGUID = dr["FMEAOwnerGUID"].ToString().Trim();
                            }
                        }

                        string RelevantRisk = (dataItem.FindControl("txtRelevantrisk_Edit") as RadEditor).Content.Trim();
                        string MitigationItem = (dataItem.FindControl("txtMTEdit") as RadEditor).Content.Trim();
                        string URL = (dataItem.FindControl("txtURL") as TextBox).Text.Trim();
                        string strAction = Convert.ToString(CommonConstantVariables.UPDATEACTION_VALUE);

                        if (!(string.IsNullOrEmpty(Convert.ToString(dataItem.GetDataKeyValue("CMSFMEAID")))))
                        {
                            alOutPutParam = objFMEAMaintenanceBLL.SetCMSFMEAv2(Convert.ToString(dataItem.GetDataKeyValue("CMSFMEAID")), FMEAName, FMEAType, FMEAOwnerGUID, RelevantRisk, MitigationItem, cmsProjectNumber, cmsStageId, URL, strAction, modifiedBy);

                        }
                        else
                        {
                            alOutPutParam = objFMEAMaintenanceBLL.SetCMSFMEAv2(string.Empty, FMEAName, FMEAType, FMEAOwnerGUID, RelevantRisk, MitigationItem, cmsProjectNumber, cmsStageId, URL, strAction, modifiedBy);
                        }
                        actionItemID = alOutPutParam[0].ToString(); //this will give action item id
                        sMessage = alOutPutParam[2].ToString();
                        //if an action has been created, then Send Actio Item Mail
                        if (!string.IsNullOrEmpty(actionItemID))
                        {
                            dtActionItems = objActionItems.GetCMSActionItems(this.cmsProjectNumber, loggedinGUID).Tables[0];
                            DataView dvAssignedTo = dtActionItems.DefaultView;

                            dvAssignedTo.RowFilter = "ActionItemID=" + actionItemID + "";
                            if (dvAssignedTo.ToTable().Rows.Count > 0)
                            {
                                assignedToMail = dvAssignedTo.ToTable().Rows[0]["Email"].ToString();
                            }
                            actionItemTab = Convert.ToString(ConfigurationManager.AppSettings["CMSBundleReviewsite"]) + CommonConstantVariables.CMSDashboardTab + cmsProjectNumber + "&Actionitem=actionitem";
                            link = string.Format(CommonConstantVariables.ACTIONITEM_LINK2, actionItemTab);
                            mail = string.Format(CommonConstantVariables.MAIL_FORMAT, CommonConstantVariables.ACTIONITEM_HEADING, CommonConstantVariables.PROGRAM_NUMBER,
                                cmsProjectNumber, CommonConstantVariables.CHANGE_TITLE, alOutPutParam[1].ToString(), CommonConstantVariables.ACTIONITEM_ID, actionItemID,
                                CommonConstantVariables.ACTION_ITEM, "FMEA " + FMEAName + " risk analysis and all relevant updates completed", link);

                            SendMail(assignedToMail, string.Empty, string.Empty, CommonConstantVariables.SUBJECT_TASKHOLDER, mail + ".");
                        }
                        ///Display the message
                        if (sMessage.Contains("ERROR") || sMessage.Contains("exists"))
                        {
                            objCommonMethods.DisplayMessage(lblMessage, "Error", sMessage);
                        }
                        else
                        {
                            objCommonMethods.DisplayMessage(lblMessage, "Info", sMessage);
                        }

                    }
                }
                else
                {
                    objCommonMethods.DisplayMessage(lblMessage, "Error", "Session has expired.");
                }
            }
            catch (Exception ex)
            {
                objCommonMethods.DisplayMessage(lblMessage, "Error", "Error occurred while saving FMEA data.");
                objCommonMethods.GenericExceptionMethod(ex);
            }
        }

        /// <summary>
        /// Sending mail
        /// </summary>
        /// <param name="to">AssignedTo</param>
        /// <param name="bcc">BCC</param>
        /// <param name="cc">CC</param>
        /// <param name="subject">Action item Description</param>
        /// <param name="body">Action item details</param>
        /// <returns></returns>
        public string SendMail(string to, string bcc, string cc, string subject, string body)
        {
            objCommonMethods = new CommonMethods();
            string stroutparameter = string.Empty;
            try
            {
                MailMessage objMessage = new MailMessage();
                SmtpClient smtpClient = new SmtpClient();
                smtpClient.Host = ConfigurationManager.AppSettings["SmtpServer"].Trim();
                string frommail = ConfigurationManager.AppSettings["FromMail"].ToString();
                objMessage.From = new MailAddress(frommail);
                objMessage.Subject = subject;
                objMessage.Body = body;
                objMessage.IsBodyHtml = true;
                objMessage.Priority = MailPriority.High;
                if ((to != null) && (to != string.Empty))
                {
                    // Set the To address of the mail message
                    objMessage.To.Add(new MailAddress(to));
                }
                if ((bcc != null) && (bcc != string.Empty))
                {
                    // Set the Bcc address of the mail message
                    objMessage.Bcc.Add(new MailAddress(bcc));
                }

                if ((cc != null) && (cc != string.Empty))
                {
                    // Set the CC address of the mail message
                    objMessage.CC.Add(new MailAddress(cc));
                }
                smtpClient.Send(objMessage);
            }
            catch (Exception ex)
            {
                new CMSException("CMS", cmsProjectNumber, "Error", ex.Message, ex.StackTrace, "Error occurred while sending mail.", "");
                stroutparameter = ex.Message + "Error occurred while sending mail";
                objCommonMethods.GenericExceptionMethod(ex);
            }

            return stroutparameter;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdFMEA_ItemCreated(object sender, GridItemEventArgs e)
        {
            try
            {
                ImageButton imgInsert = null;

                if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    RequiredFieldValidator rfvFMEAType = (RequiredFieldValidator)e.Item.FindControl("rfvFMEAType");
                    RequiredFieldValidator rfvFMEANameEdit = (RequiredFieldValidator)e.Item.FindControl("rfvFMEANameEdit");
                    RequiredFieldValidator rfvRelevantrisk_Edit = (RequiredFieldValidator)e.Item.FindControl("rfvRelevantrisk_Edit");
                    RequiredFieldValidator rfvMitigationAction = (RequiredFieldValidator)e.Item.FindControl("rfvMitigationAction");

                    if (!(e.Item is IGridInsertItem))
                    {
                        imgInsert = (ImageButton)e.Item.FindControl("UpdateButton");
                        imgInsert.ValidationGroup = "Edit";
                        imgInsert.CausesValidation = true;
                        rfvFMEAType.ValidationGroup = "Edit";
                        rfvFMEANameEdit.ValidationGroup = "Edit";
                        rfvRelevantrisk_Edit.ValidationGroup = "Edit";
                        rfvMitigationAction.ValidationGroup = "Edit";
                        rfvFMEANameEdit.Enabled = true;
                    }
                    else
                    {
                        imgInsert = (ImageButton)e.Item.FindControl("PerformInsertButton");
                        imgInsert.CausesValidation = true;
                        imgInsert.ValidationGroup = "Insert";

                        rfvFMEAType.ValidationGroup = "Insert";
                        rfvFMEANameEdit.ValidationGroup = "Insert";
                        rfvRelevantrisk_Edit.ValidationGroup = "Insert";
                        rfvMitigationAction.ValidationGroup = "Insert";
                        rfvFMEANameEdit.Enabled = true;

                    }

                }
            }
            catch (Exception ex)
            {
                objCommonMethods.GenericExceptionMethod(ex);
                objCommonMethods.DisplayMessage(lblMessage, "Error", "Error occurred while creating a new item.");
            }
        } 
0
Kostadin
Telerik team
answered on 26 Jan 2015, 08:13 AM
Hi Aman,

I examined the provided code and I was unable to find what might be the reason for the missing items after postback. I noticed that you have AJAX-enabled RadGrid so could you please disable it and check whether some server side error is not throwing. You can achieved that by setting EnableAJAX to false to the RadAjaxManager control. Additionally I would appreciate if you can isolate the issue in a small runnable sample and paste the code in this thread.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Aman
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Aman
Top achievements
Rank 1
Share this question
or