Solved

Problem in the Update of a Gridview

Posted on 2008-10-27
10
783 Views
Last Modified: 2013-12-17
Hi Experts,

The "Update" of the gridview is not working at all not. When clicking on it, nothing happens and the row state remains the same in the edit mode.

I have one page that contains several user controls, between them:
+ QIR
       + departmentlist
+ ImpInvestigation

There are 2  gridviews is in the "ImpInvestigation" user control which both of them are facing the same problem. The weird thing is that when I remove the "departmentlist" usercontrol from the QIR user control, it works fine. But when I put in a seperate page both user controls the QIR and ImpInvestigation, the gridviews work fine.

Can you please help me?
0
Comment
Question by:Salim Fayad
  • 5
  • 4
10 Comments
 
LVL 10

Expert Comment

by:jinn_hnnl
ID: 22810764
How do you add and bind these usercontrol to your page? Dynamically I guess?

Do you use update panel?, if you do there will be major problem as partial page will be updated, the build order will be different so those update, ok cancel button has different ID (auto generated) before and after page postback, this can cause button click unregistered and not firing. You see them but you dont see the same one after postback technically

For example: before postback you have ct001_ct002_ct005_gvdepartmentlist
after:  ct001_ct002_ct003_gvdepartmentlist
Same problem can happen for buttons (like ok cancel)...  

Be aware of this problem when you have nested or dynamically added usercontrols. And make sure the gridviews are binded properly.

When you remove 1 gridview out of the control, or separate them, usercontrols have same build order (hardly change when there is less to build). Then problem unintentionally solved.

Hope this give you some ideas

JINN


0
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22810874
did your gridview contain datakeysName property ... if not add that and check
0
 
LVL 11

Author Comment

by:Salim Fayad
ID: 22811005
jinn_hnnl,
I am binding the gridviews using an object data source, and no I am not using an UpdatePanel control
 
BondingASP,
The 2 gridviews contain datakeyNames
0
 
LVL 10

Expert Comment

by:jinn_hnnl
ID: 22811078
Well, in that case, can you paste these parts of your code, where you bind your gridView, and how you add those usercontrols (which contains the GV to your page)?
JINN
0
 
LVL 11

Author Comment

by:Salim Fayad
ID: 22811106
Here is the code (the ascx and not the cs)
ImpInvestigation UserControl:

---------------------------
 

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ImpInvestigation.ascx.cs"

    Inherits="Applications_QIR_ImpInvestigation" %>

<%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %>

<%@ Register Src="~/Applications/QIR/QIRRootCause.ascx" TagName="SelectRootCause"

    TagPrefix="uc1" %>

<%@ Register Namespace="Sabic.Web.Library" TagPrefix="WebLibrary" %>

<%@ Register TagPrefix="rapidspellweb" Namespace="Keyoti.RapidSpell" Assembly="Keyoti.RapidSpellWeb.ASP.NETv2" %>

<table width="100%">

    <tr>

        <td>

            <h1>

                <asp:Label ID="lblRootCause" runat="server" Text="Causes"></asp:Label>

            </h1>

        </td>

    </tr>

    <tr>

        <td>

            <uc1:SelectRootCause ID="ucSelectRootCause1" runat="server" />

        </td>

    </tr>

    <tr>

        <td>

            <table>

                <tr>

                    <td colspan="4">

                        <asp:Label ID="lblDescription" runat="server" Text="Description "></asp:Label></td>

                </tr>

                <tr>

                    <td colspan="2">

                        <asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" Width="300"

                            Rows="5"></asp:TextBox>

                    </td>

                    <td valign="bottom">

                        <rapidspellweb:RapidSpellWInline RightClickForMenu="true" ID="btnDescription" runat="server"

                            ButtonTextSpellMode="Spell Check" AutoLaunchWhenTextInvalid="True" ConsiderationRange="500"

                            RapidSpellWInlineHelperPage="../../RapidSpellHelper/rswihelper.aspx" TextComponentID="txtDescription"

                            Validator="True">

                            <Button CssClass="asp_Button" type="button" Value="Spell Check" ID="btnSpellCheck1">

                            </Button>

                        </rapidspellweb:RapidSpellWInline>

                    </td>

                    <td valign="bottom">

                        <asp:Button ID="btnAdd" ValidationGroup="grpSelectClause" runat="server" Text="Add"

                            OnClick="btnAdd_Click" /></td>

                </tr>

            </table>

        </td>

    </tr>

    <tr>

        <td>

            <asp:GridView ID="grvCauses" RowStyle-HorizontalAlign="Center" runat="server" Width="80%"

                AutoGenerateColumns="False" DataKeyNames="iD" DataSourceID="odsCauses" OnRowDataBound="grvCauses_RowDataBound"

                OnRowUpdated="grvCauses_RowUpdated">

                <Columns>

                    <asp:TemplateField HeaderText="Cause">

                        <ItemTemplate>

                            <asp:TreeView ID="grvCauses_trvCauses" runat="server" ExpandDepth="FullyExpand">

                            </asp:TreeView>

                            <asp:Label ID="grvCauses_lblCauseID" runat="server" Text='<%#Bind("CauseID") %>'

                                Visible="false"></asp:Label>

                        </ItemTemplate>

                        <EditItemTemplate>

                            <uc1:SelectRootCause ID="ucSelectRootCause2" CauseID='<%# Bind("CauseID") %>' runat="server" />

                            <asp:Label ID="grvCauses_lblQIRID" runat="server" Text='<%# Bind("QIRID") %>' Visible="true"></asp:Label>

                        </EditItemTemplate>

                        <ItemStyle HorizontalAlign="Left" />

                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Description">

                        <ItemTemplate>

                            <asp:Label ID="lblDescription" runat="server" Text='<%# Eval("Description") %>'> </asp:Label>

                        </ItemTemplate>

                        <EditItemTemplate>

                            <asp:TextBox ID="txtDescription" runat="server" Text='<%# Bind("Description") %>'

                                TextMode="MultiLine"></asp:TextBox>

                        </EditItemTemplate>

                    </asp:TemplateField>

                    <asp:TemplateField ShowHeader="False">

                        <EditItemTemplate>

                            <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="True" CommandName="Update"

                                Text="Update"></asp:LinkButton>

                            <asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="False" CommandName="Cancel"

                                Text="Cancel"></asp:LinkButton>

                        </EditItemTemplate>

                        <ItemTemplate>

                            <asp:LinkButton ID="lnkEdit" runat="server" CausesValidation="False" CommandName="Edit"

                                Text="Edit"></asp:LinkButton>

                        </ItemTemplate>

                    </asp:TemplateField>

                    <asp:TemplateField ShowHeader="False">

                        <ItemTemplate>

                            <asp:LinkButton ID="lnkDelete" runat="server" OnClientClick="javascript:return confirm('Are You Sure?');"

                                CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton>

                        </ItemTemplate>

                    </asp:TemplateField>

                </Columns>

                <RowStyle HorizontalAlign="Center" />

            </asp:GridView>

            <asp:ObjectDataSource ID="odsCauses" runat="server" DeleteMethod="DeleteQIR_Cause"

                InsertMethod="AddQIR_Cause" SelectMethod="SearchQIR_Cause" TypeName="Sabic.QIR.Applications.QIRController"

                UpdateMethod="UpdateQIR_Cause">

                <DeleteParameters>

                    <asp:Parameter Name="iD" Type="Int32" />

                </DeleteParameters>

                <UpdateParameters>

                    <asp:Parameter Name="iD" Type="Int32" />

                    <asp:Parameter Name="qIRID" Type="Int32" />

                    <asp:Parameter Name="causeID" Type="Int32" />

                    <asp:Parameter Name="description" Type="String" />

                </UpdateParameters>

                <SelectParameters>

                    <asp:Parameter DefaultValue="-1" Name="iD" Type="Int32" />

                    <asp:Parameter Name="qIRID" Type="Int32" />

                    <asp:Parameter DefaultValue="-1" Name="causeID" Type="Int32" />

                    <asp:Parameter Name="description" Type="String" />

                    <asp:Parameter Name="createdUser" Type="String" />

                    <asp:Parameter Name="createdDate" Type="DateTime" />

                    <asp:Parameter Name="modifiedUser" Type="String" />

                    <asp:Parameter Name="modifiedDate" Type="DateTime" />

                </SelectParameters>

                <InsertParameters>

                    <asp:Parameter Name="qIRID" Type="Int32" />

                    <asp:Parameter Name="causeID" Type="Int32" />

                    <asp:Parameter Name="description" Type="String" />

                </InsertParameters>

            </asp:ObjectDataSource>

            &nbsp;

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label ID="lblCorrectiveAction" runat="server" Text="Corrective Actions"></asp:Label>

            </h1>

        </td>

    </tr>

    <tr>

        <td>

            <table>

                <tr>

                    <td>

                        <asp:Label ID="lblActions" runat="server" Text="Corrective Action"></asp:Label></td>

                    <td>

                        <asp:TextBox ID="txtCorrectiveAction" runat="server"></asp:TextBox><rapidspellweb:RapidSpellWInline

                            RightClickForMenu="true" ID="btnCorrectiveAction" runat="server" ButtonTextSpellMode="Spell Check"

                            AutoLaunchWhenTextInvalid="True" ConsiderationRange="500" RapidSpellWInlineHelperPage="../../RapidSpellHelper/rswihelper.aspx"

                            TextComponentID="txtCorrectiveAction" Validator="True">

                            <Button CssClass="asp_button" type="button" Value="Spell Check" ID="btnSpellCheck2">

                            </Button>

                        </rapidspellweb:RapidSpellWInline>

                        <asp:RequiredFieldValidator ID="rfvCorrectiveAction" runat="server" ControlToValidate="txtCorrectiveAction"

                            ErrorMessage="Please enter a corrective action" ValidationGroup="CorrectiveActionAdd"

                            Text="*"></asp:RequiredFieldValidator>

                    </td>

                    <td>

                        <asp:Label ID="lblTargetDate" runat="server" Text="Target Date"></asp:Label></td>

                    <td>

                        <ew:CalendarPopup ID="calTargetDate" runat="server">

                        </ew:CalendarPopup>

                    </td>

                    <td>

                    </td>

                    <td>

                        <asp:Button ID="btnAddAction" runat="server" Text="Add" ValidationGroup="CorrectiveActionAdd"

                            OnClick="btnAddAction_Click" /><asp:ValidationSummary ID="vsImpInvestigation" runat="server"

                                ShowMessageBox="True" ShowSummary="False" ValidationGroup="CorrectiveActionAdd" />

                    </td>

                </tr>

            </table>

        </td>

    </tr>

    <tr>

        <td>

            <asp:GridView RowStyle-HorizontalAlign="Center" ID="grvCorrectiveAction" Width="80%"

                runat="server" DataKeyNames="ID" AutoGenerateColumns="False" DataSourceID="odsCorrectiveActions"

                OnRowDataBound="grvCorrectiveAction_RowDataBound">

                <Columns>

                    <asp:TemplateField HeaderText="Action">

                        <ItemTemplate>

                            <asp:Label runat="server" ID="grvCorrectiveAction_lblCorrectiveAction" Text='<%#Bind("Description") %>'></asp:Label>

                            <asp:TextBox runat="server" Visible="false" ID="txtQIRID2" Text='<%#Bind("QIRID") %>'></asp:TextBox>

                        </ItemTemplate>

                        <EditItemTemplate>

                            <asp:TextBox runat="server" ID="grvCorrectiveAction_txtCorrectiveAction" Text='<%#Bind("Description") %>'></asp:TextBox>

                            <asp:TextBox runat="server" Visible="false" ID="txtQIRID2" Text='<%#Bind("QIRID") %>'></asp:TextBox>

                        </EditItemTemplate>

                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Target Date">

                        <ItemTemplate>

                            <asp:Label runat="server" ID="grvCorrectiveAction_lblTargetDate" Text='<%# Utility.ConvertToDateTime(Eval("TargetDate").ToString()).ToShortDateString() %>'></asp:Label>

                        </ItemTemplate>

                        <EditItemTemplate>

                            <ew:CalendarPopup ID="grvCorrectiveAction_calTargetDate" SelectedDate='<%# Bind("TargetDate") %>'

                                runat="server">

                            </ew:CalendarPopup>

                        </EditItemTemplate>

                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Completion Date" Visible="False">

                        <ItemTemplate>

                            <ew:CalendarPopup ID="grvCorrectiveAction_calCompletionDate" Visible="false" SelectedDate='<%# Bind("CompletionDate") %>'

                                runat="server">

                            </ew:CalendarPopup>

                            <asp:CompareValidator ID="cvCompletionDate" runat="server" Display="Dynamic" ErrorMessage="Completion Date should be bigger than Target Date"

                                Operator="GreaterThan" ControlToValidate="grvCorrectiveAction_calCompletionDate"

                                ControlToCompare="grvCorrectiveAction_calTargetDate2" SetFocusOnError="True"

                                Type="Date">*</asp:CompareValidator>

                            <ew:CalendarPopup ID="grvCorrectiveAction_calTargetDate2" Visible="false" Width="50px"

                                SelectedDate='<%# Bind("TargetDate") %>' runat="server">

                            </ew:CalendarPopup>

                        </ItemTemplate>

                    </asp:TemplateField>

                    <asp:TemplateField ShowHeader="False">

                        <EditItemTemplate>

                            <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="True" CommandName="Update"

                                Text="Update"></asp:LinkButton>

                            <asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="False" CommandName="Cancel"

                                Text="Cancel"></asp:LinkButton>

                        </EditItemTemplate>

                        <ItemTemplate>

                            <asp:LinkButton ID="lnkEdit" runat="server" CausesValidation="False" CommandName="Edit"

                                Text="Edit"></asp:LinkButton>

                        </ItemTemplate>

                    </asp:TemplateField>

                    <asp:TemplateField ShowHeader="False">

                        <ItemTemplate>

                            <asp:LinkButton ID="lnkDelete" runat="server" OnClientClick="javascript:return confirm('Are You Sure?');"

                                CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton>

                        </ItemTemplate>

                    </asp:TemplateField>

                </Columns>

                <RowStyle HorizontalAlign="Center" />

            </asp:GridView>

        </td>

    </tr>

</table>

<asp:ObjectDataSource ID="odsCorrectiveActions" runat="server" SelectMethod="SearchCorrectiveAction"

    TypeName="Sabic.QIR.Applications.QIRController" InsertMethod="AddCorrectiveAction"

    DeleteMethod="DeleteCorrectiveAction" UpdateMethod="UpdateCorrectiveAction">

    <SelectParameters>

        <asp:Parameter DefaultValue="-1" Name="iD" Type="Int32" />

        <asp:Parameter Name="qIRID" Type="Int32" />

        <asp:Parameter DefaultValue="" Name="description" Type="String" />

        <asp:Parameter Name="targetDate" Type="DateTime" />

        <asp:Parameter Name="completionDate" Type="DateTime" />

        <asp:Parameter Name="createdUser" Type="String" />

        <asp:Parameter Name="createdDate" Type="DateTime" />

        <asp:Parameter Name="modifiedUser" Type="String" />

        <asp:Parameter Name="modifiedDate" Type="DateTime" />

    </SelectParameters>

    <InsertParameters>

        <asp:Parameter Name="qIRID" Type="Int32" />

        <asp:Parameter Name="description" Type="String" />

        <asp:Parameter Name="targetDate" Type="DateTime" />

        <asp:Parameter Name="completionDate" Type="DateTime" />

    </InsertParameters>

    <DeleteParameters>

        <asp:Parameter Name="iD" Type="Int32" />

    </DeleteParameters>

    <UpdateParameters>

        <asp:Parameter Name="iD" Type="Int32" />

        <asp:Parameter Name="qIRID" Type="Int32" />

        <asp:Parameter Name="description" Type="String" />

        <asp:Parameter Name="targetDate" Type="DateTime" />

        <asp:Parameter Name="completionDate" Type="DateTime" />

    </UpdateParameters>

</asp:ObjectDataSource>
 

--------------------------------------------------------

QIR:

---

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="QIR.ascx.cs" Inherits="Applications_QIR_QIR" %>

<%@ Register Src="departmentlist.ascx" TagName="departmentlist" TagPrefix="uc3" %>

<%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %>

<%@ Register TagPrefix="rapidspellweb" Namespace="Keyoti.RapidSpell" Assembly="Keyoti.RapidSpellWeb.ASP.NETv2" %>

<table width="100%" cellpadding="0" cellspacing="0">

    <tr>

        <td>

            <asp:Label Text="QIR Number" ID="lblQIRNum" runat="server" Visible="false" CssClass="Header1"></asp:Label>

        </td>

    </tr>

    <tr>

        <td>

            <asp:Label ID="lblQIRNumber" runat="server" Visible="false"></asp:Label>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblQIRTitle" ID="lblQIRTitle" runat="server"></asp:Label></h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <asp:TextBox ID="txtTitle" runat="server" Width="200px"></asp:TextBox>

            <asp:RequiredFieldValidator meta:resourcekey="RequiredFieldValidator1" ID="RequiredFieldValidator1"

                runat="server" ControlToValidate="txtTitle" ValidationGroup="SaveWithoutSubmitting">*</asp:RequiredFieldValidator>

            <asp:RequiredFieldValidator meta:resourcekey="RequiredFieldValidator3" ID="RequiredFieldValidator3"

                runat="server" ControlToValidate="txtTitle" ValidationGroup="Submit">*</asp:RequiredFieldValidator></td>

        <td>

        </td>

    </tr>

    <tr>

        <td colspan="2">

            <rapidspellweb:RapidSpellWInline RightClickForMenu="true" ID="btnTitle"

                runat="server" ButtonTextSpellMode="Spell Check" AutoLaunchWhenTextInvalid="True"

                ConsiderationRange="500" RapidSpellWInlineHelperPage="../../RapidSpellHelper/rswihelper.aspx"

                TextComponentID="txtTitle" Validator="True">

                <Button BorderWidth="" BorderColor="" ForeColor="" BackColor="" Height="" Width=""

                    CssClass="" type="button" Value="Spell Check" ID="Button4"></Button>

            </rapidspellweb:RapidSpellWInline>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblDateCreated" ID="lblDateCreated" runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <asp:Label ID="lblCreatedDate" runat="server" Text="Label"></asp:Label>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblOccuredDate" ID="lblOccuredDate" runat="server"></asp:Label></h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <ew:CalendarPopup ID="calOccuredDate" runat="server" Width="200px">

            </ew:CalendarPopup>

            <asp:RequiredFieldValidator meta:resourcekey="DateOccuredRequired" ID="DateOccuredRequired"

                runat="server" ControlToValidate="calOccuredDate" ValidationGroup="Submit">*</asp:RequiredFieldValidator>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblOccuredTime" ID="lblOccuredTime" runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <ew:TimePicker ID="calOccuredDateTime" runat="server" Width="200px">

            </ew:TimePicker>

            <asp:RequiredFieldValidator meta:resourcekey="TimeOccuredRequired" ID="TimeOccuredRequired"

                runat="server" ControlToValidate="calOccuredDateTime" ValidationGroup="Submit">*</asp:RequiredFieldValidator></td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblOriginatingDeptTitle" ID="lblOriginatingDeptTitle"

                    runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <asp:Label meta:resourcekey="lblOriginatingDept" ID="lblOriginatingDept" runat="server"

                Text="Label"></asp:Label>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblConcernedDept" ID="lblConcernedDept" runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            &nbsp;<uc3:departmentlist ID="uscDepartmentlist" runat="server" />

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblLocation" ID="lblLocation" runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <asp:TextBox ID="txtLocation" runat="server" Width="200px"></asp:TextBox>

            <asp:RequiredFieldValidator meta:resourcekey="LocationRequired" ID="LocationRequired"

                runat="server" ControlToValidate="txtLocation" ValidationGroup="Submit">*</asp:RequiredFieldValidator></td>

        <td>

        </td>

    </tr>

    <tr>

        <td colspan="2">

            <rapidspellweb:RapidSpellWInline RightClickForMenu="true" ID="btnLocation"

                runat="server" ButtonTextSpellMode="Spell Check" AutoLaunchWhenTextInvalid="True"

                ConsiderationRange="500" RapidSpellWInlineHelperPage="../../RapidSpellHelper/rswihelper.aspx"

                TextComponentID="txtLocation" Validator="True">

                <Button BorderWidth="" BorderColor="" ForeColor="" BackColor="" Height="" Width=""

                    CssClass="" type="button" Value="Spell Check" ID="Button5"></Button>

            </rapidspellweb:RapidSpellWInline>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblEquipmentNb" ID="lblEquipmentNb" runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <asp:TextBox ID="txtEquipmentNb" runat="server" Width="200px"></asp:TextBox>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td colspan="2">

            <rapidspellweb:RapidSpellWInline RightClickForMenu="true" ID="btnEquipmentNb"

                runat="server" ButtonTextSpellMode="Spell Check" AutoLaunchWhenTextInvalid="True"

                ConsiderationRange="500" RapidSpellWInlineHelperPage="../../RapidSpellHelper/rswihelper.aspx"

                TextComponentID="txtEquipmentNb" Validator="True">

                <Button BorderWidth="" BorderColor="" ForeColor="" BackColor="" Height="" Width=""

                    CssClass="" type="button" Value="Spell Check" ID="Button6"></Button>

            </rapidspellweb:RapidSpellWInline>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblEquipmentName" ID="lblEquipmentName" runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <asp:TextBox ID="txtEquipmentName" runat="server" Width="200px"></asp:TextBox>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblEventDesc" ID="lblEventDesc" runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <asp:TextBox ID="txtEventDescription" runat="server" TextMode="MultiLine" Height="95px"

                Width="625px"></asp:TextBox>

            <asp:RequiredFieldValidator meta:resourcekey="DescritptionRequired" ID="DescritptionRequired"

                runat="server" ControlToValidate="txtEventDescription" ValidationGroup="Submit">*</asp:RequiredFieldValidator></td>

        <td>

        </td>

    </tr>

    <tr>

        <td colspan="2">

            <rapidspellweb:RapidSpellWInline RightClickForMenu="true" ID="btnEventDescription"

                runat="server" ButtonTextSpellMode="Spell Check" AutoLaunchWhenTextInvalid="True"

                ConsiderationRange="500" RapidSpellWInlineHelperPage="../../RapidSpellHelper/rswihelper.aspx"

                TextComponentID="txtEventDescription" Validator="True">

                <Button BorderWidth="" BorderColor="" ForeColor="" BackColor="" Height="" Width=""

                    CssClass="" type="button" Value="Spell Check" ID="Button1"></Button>

            </rapidspellweb:RapidSpellWInline>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblImmidiateActionTaken" ID="lblImmidiateActionTaken"

                    runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <asp:TextBox ID="txtActionTaken" runat="server" TextMode="MultiLine" Height="95px"

                Width="625px"></asp:TextBox>

            <asp:RequiredFieldValidator meta:resourcekey="ImmidiateActionRequired" ID="ImmidiateActionRequired"

                runat="server" ControlToValidate="txtActionTaken" ValidationGroup="Submit">*</asp:RequiredFieldValidator></td>

        <td>

        </td>

    </tr>

    <tr>

        <td colspan="2">

            <rapidspellweb:RapidSpellWInline RightClickForMenu="true" ID="btnActionTaken"

                runat="server" ButtonTextSpellMode="Spell Check" AutoLaunchWhenTextInvalid="True"

                ConsiderationRange="500" RapidSpellWInlineHelperPage="../../RapidSpellHelper/rswihelper.aspx"

                TextComponentID="txtActionTaken" Validator="True">

                <Button BorderWidth="" BorderColor="" ForeColor="" BackColor="" Height="" Width=""

                    CssClass="" type="button" Value="Spell Check" ID="Button2"></Button>

            </rapidspellweb:RapidSpellWInline>

        </td>

    </tr>

    <tr>

        <td>

            <h1>

                <asp:Label meta:resourcekey="lblSuggestion" ID="lblSuggestion" runat="server"></asp:Label>

            </h1>

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td>

            <asp:TextBox ID="txtSuggestion" runat="server" TextMode="MultiLine" Height="95px"

                Width="625px"></asp:TextBox>

            <asp:ValidationSummary ID="vlsError" runat="server" ShowMessageBox="true" ShowSummary="false"

                ValidationGroup="Submit" />

            <asp:ValidationSummary ID="vlsErrorSave" runat="server" ShowMessageBox="true" ShowSummary="false"

                ValidationGroup="SaveWithoutSubmitting" />

        </td>

        <td>

        </td>

    </tr>

    <tr>

        <td colspan="2">

            <rapidspellweb:RapidSpellWInline RightClickForMenu="true" ID="btnSuggestion"

                runat="server" ButtonTextSpellMode="Spell Check" AutoLaunchWhenTextInvalid="True"

                ConsiderationRange="500" RapidSpellWInlineHelperPage="../../RapidSpellHelper/rswihelper.aspx"

                TextComponentID="txtSuggestion" Validator="True">

                <Button BorderWidth="" BorderColor="" ForeColor="" BackColor="" Height="" Width=""

                    CssClass="" type="button" Value="Spell Check" ID="Button3"></Button>

            </rapidspellweb:RapidSpellWInline>

        </td>

    </tr>

</table>

--------------------------------------

DepartmentList:

-------------
 

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="departmentlist.ascx.cs" Inherits="departmentlist" %>

<table>

    <tr id="trDivision" runat="server" style="Display:none">

        <td style="width: 274px">

            Division<br />

            <asp:DropDownList ID="drpDivision" runat="server" AutoPostBack="True" OnSelectedIndexChanged="drpDivision_SelectedIndexChanged">

            </asp:DropDownList>

            <asp:RequiredFieldValidator ID="rfvDivision" runat="server" ErrorMessage="Please select division" ControlToValidate="drpDivision" Display="Dynamic" InitialValue="-1" ValidationGroup="Submit">*</asp:RequiredFieldValidator></td>

    </tr>

    <tr id="trSubDivision" runat="server" style="Display:none">

        <td style="width: 274px">

            Sub Division<br />

            <asp:DropDownList ID="drpSubDivision" runat="server" AutoPostBack="True" OnSelectedIndexChanged="drpSubDivision_SelectedIndexChanged">

            </asp:DropDownList>

            <asp:RequiredFieldValidator ID="rfvSubdivision" runat="server" ErrorMessage="Please select sub division" ControlToValidate="drpSubDivision" Display="Dynamic" InitialValue="-1" ValidationGroup="Submit">*</asp:RequiredFieldValidator></td>

    </tr>

    <tr id="trDepartment" runat="server" style="Display:none">

        <td style="width: 274px" >

            Department<br />

            <asp:DropDownList ID="drpDepartment" runat="server" AutoPostBack="True" OnSelectedIndexChanged="drpDepartment_SelectedIndexChanged">

            </asp:DropDownList>

            <asp:RequiredFieldValidator ID="rfvDept" runat="server" ErrorMessage="Please select department" ControlToValidate="drpDepartment" Display="Dynamic" InitialValue="-1" ValidationGroup="Submit">*</asp:RequiredFieldValidator>

        </td>

    </tr>

    <tr id="trSection" runat="server" style="Display:none">

        <td style="width: 274px">

            Section<br />

            <asp:DropDownList ID="drpSection" runat="server" AutoPostBack="True">

            </asp:DropDownList>

            <asp:ValidationSummary ID="vdsSummary" runat="server" ShowMessageBox="True" ShowSummary="False" />

        </td>

    </tr>

</table>

Open in new window

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 10

Expert Comment

by:jinn_hnnl
ID: 22811281
And the parent page which you add the 2 usercontrols ImpInvestigation and QIR???
I have run through your code quickly and appear to me they are fine. I need to know the relation between that 2 controls

As you mentioned when you remove the DepartmentList from your QIR usercontrols everything is fine. The DepartmentList is the childControl of QIR, when this control changes it makes changes to the 1st control ImpInvestigation <--- this my be the key. (especially when you said: "But when I put in a seperate page both user controls the QIR and ImpInvestigation, the gridviews work fine"

What the relation between the 2 big controls then ?

JINN
0
 
LVL 11

Author Comment

by:Salim Fayad
ID: 22811917
There is no direct relation between the 2 big controls. Here is the code of the page that contains both controls:
ASPX:

---

<%@ Page MasterPageFile="~/MasterPage.master" Language="C#" AutoEventWireup="true"

    CodeFile="ImpQIRInvestigation.aspx.cs" Inherits="UI_QIR_ImpQIRInvestigation" %>
 

<%@ Register Src="~/Applications/QIR/ImpInvestigation.ascx" TagName="ImpInvestigation"

    TagPrefix="uc8" %>

<%@ Register Src="../../Applications/QIR/CDMQIRApprove.ascx" TagName="CDMQIRApprove"

    TagPrefix="uc7" %>

<%@ Register Src="../../Applications/QIR/IDMQIR.ascx" TagName="IDMQIR" TagPrefix="uc6" %>

<%@ Register Src="../../Applications/WorkflowControls/ActionsControl.ascx" TagName="ActionsControl"

    TagPrefix="uc5" %>

<%@ Register Src="../../Applications/WorkflowControls/AttachmentControl.ascx" TagName="AttachmentControl"

    TagPrefix="uc4" %>

<%@ Register Src="../../Applications/WorkflowControls/CommentsControl.ascx" TagName="CommentsControl"

    TagPrefix="uc3" %>

<%@ Register Src="../../Applications/WorkflowControls/ProcessFormHeader.ascx" TagName="ProcessFormHeader"

    TagPrefix="uc2" %>

<%@ Register Src="../../Applications/QIR/QIR.ascx" TagName="QIR" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="phdMain" runat="server">

    <table width="100%">

        <tr>

            <td>

                <uc2:ProcessFormHeader ID="uscProcessFormHeader" runat="server"></uc2:ProcessFormHeader>

            </td>

        </tr>

        <tr>

            <td>

                <uc1:QIR ID="uscQIR" runat="server" />

            </td>

        </tr>

        <tr>

            <td>

                <uc6:IDMQIR ID="uscIDMQIR" runat="server" />

            </td>

        </tr>

        <tr>

            <td>

                <uc8:ImpInvestigation CurrentMode="Write" ID="uscImpInvestigation" runat="server" />

            </td>

        </tr>

        <tr>

            <td>

                <uc3:CommentsControl ID="uscCommentsControl" runat="server" AllowEnterComments="true"

                    ShowEnteredComments="true" ShowOnlyLastComments="false"></uc3:CommentsControl>

            </td>

        </tr>

        <tr>

            <td>

                <uc4:AttachmentControl ID="uscAttachmentControl" runat="server" AllowViewUploadedFiles="true" />

            </td>

        </tr>

        <tr>

            <td align="center">

                <uc5:ActionsControl ID="uscActionsControl" runat="server" />

                <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"

                    ValidationGroup="Submit" />

            </td>

        </tr>

    </table>

</asp:Content>
 

------------------------------

CS:

--

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using Sabic.QIR.Applications;

using Sabic.Web.Library;

using System.Collections.Generic;

using System.Collections.Specialized;

using Sabic.QIR.Applications.Controller;
 

public partial class UI_QIR_ImpQIRInvestigation : BasePage

{

    #region Methods

    private void UpdateQIR(bool saved, string folio, int requestStatus)

    {

        QIRInfo qirInfo = QIRController.GetQIRById(RequestID);

        RequestController.UpdateRequest(RequestID, requestStatus, folio, saved);

        QIRController.UpdateQIR(RequestID, uscQIR.Title, uscQIR.OccuredDate, CurrentUser.CompanyCode, qirInfo.originatingDeptCode, uscQIR.ConcernedDeptCode, uscQIR.Location,

                                    uscQIR.EquipmentNb, uscQIR.EquipmentName, uscQIR.EventDescription, uscQIR.ActionTaken, uscQIR.Suggestion, qirInfo.ImplementerEmpID, Null.NullInteger, Null.NullInteger);

    }

    private void LoadQIR()

    {

        if (RequestID > 0)

        {

            QIRInfo qirInfo = QIRController.GetQIRById(RequestID);

            if (qirInfo != null)

            {

                uscQIR.QIRNumber = qirInfo.QIRNumber;

                uscQIR.CreatedDate = qirInfo.CreatedDate;

                uscQIR.OccuredDate = qirInfo.OccuredDate;

                uscQIR.Title = qirInfo.Title;

                uscQIR.OriginatingDeptCode = qirInfo.originatingDeptCode;

                uscQIR.ConcernedDeptCode = qirInfo.ConcernedDeptCode;

                uscQIR.Location = qirInfo.Location;

                uscQIR.EquipmentNb = qirInfo.EquipmentNb;

                uscQIR.EquipmentName = qirInfo.EquipmentName;

                uscQIR.EventDescription = qirInfo.EventDescription;

                uscQIR.ActionTaken = qirInfo.ActionTaken;

                uscQIR.Suggestion = qirInfo.Suggestion;

            }

        }

    }

    private void AddComments(Actions action)

    {

        RequestController.AddComments(RequestID, (int)action, (int)CurrentStage, uscCommentsControl.Comments,

            CurrentUser.EmpID, CurrentDate, GetEnumDescription(CurrentStage), GetEnumDescription(action)

            , ProcessID, CurrentDate, CurrentUser.EmpName);

        if (!ProcessID.Equals("-1"))

        {

            uscCommentsControl.ProcessID = ProcessID;

            uscCommentsControl.AddComments(GetEnumDescription(CurrentStage), GetEnumDescription(action), Page.User.Identity.Name.ToString(), CurrentUser.EmpName.ToString());

        }

    }

    private void AddAttachments()

    {

        uscAttachmentControl.ProcessID = ProcessID;

        uscAttachmentControl.AddAttachment(GetEnumDescription(CurrentStage), CurrentUser.DomainLoginID);

    }

    #endregion

    #region Events    

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            CurrentStage = Stages.ImplementorActions; 

            LoadQIR();

            uscQIR.Disabled = true;

            uscIDMQIR.Disabled = true;

            uscCommentsControl.ProcessID = ProcessID.ToString();

            uscAttachmentControl.ProcessID = ProcessID.ToString();

            uscCommentsControl.VisibleSpellCheckerCommand = true;

        }

        uscActionsControl.SelectedActionChanged += new ActionsControl.ActionEventHandler(uscAction_SelectedActionChanged);

        uscIDMQIR.EnableValidator = false;

    }

    void uscAction_SelectedActionChanged(ActionEventArgs actionArgs)

    {

        uscCommentsControl.rfvCommentsEnabled = false;

        if (actionArgs.SelectedAction == Actions.Consult || actionArgs.SelectedAction == Actions.Delegate ||

            actionArgs.SelectedAction == Actions.Reject || actionArgs.SelectedAction == Actions.Reject ||

            actionArgs.SelectedAction == Actions.SendBack)

        {

            uscCommentsControl.rfvCommentsEnabled = true;

        }

    }

    protected void SaveCompleteQIRData(bool saved, RequestStatus requestStatus, Actions userAction)

    {

        UpdateQIR(saved, ProcessID, Utility.ConvertToInt(requestStatus) );

        QIRInfo qirInfo = QIRController.GetQIRById(RequestID);
 

        SaveorUpdateQIRCauses(qirInfo);

        SaveorUpdateQIRCorrectiveActions(qirInfo);
 

        AddComments(userAction);

        if (!string.IsNullOrEmpty(SerialNo))

        {

            AddAttachments();

        }

    }

    protected void SaveorUpdateQIRCauses(QIRInfo qirInfo)

    {

        foreach (QIR_CauseInfo incidentCause in IncidentCauseList)

        {

            if (QIRController.GetQIR_CauseById(qirInfo.ID, incidentCause.CauseID) == null)

            {

                QIRController.AddQIR_Cause(qirInfo.ID, incidentCause.ID, incidentCause.Description);

            }

            else

            {

                QIRController.UpdateQIR_Cause(qirInfo.ID, qirInfo.ID, incidentCause.ID, incidentCause.Description);

            }

        }

    }

    protected void SaveorUpdateQIRCorrectiveActions(QIRInfo qirInfo)

    {

        if (QIRController.GetCorrectiveActionById(qirInfo.ID).Count <= 0)

        {

            foreach (CorrectiveActionInfo correctiveActionInfo in CorrectiveActionList)

            {

                QIRController.AddCorrectiveAction(qirInfo.ID, correctiveActionInfo.Description, correctiveActionInfo.TargetDate, Null.NullDate);

            }

        }

        else

        {

            foreach (CorrectiveActionInfo correctiveActionInfo in CorrectiveActionList)

            {

                QIRController.UpdateCorrectiveAction(qirInfo.ID, qirInfo.ID, correctiveActionInfo.Description, correctiveActionInfo.TargetDate, Null.NullDate);

            }

        }

    }

    protected void btnSubmit_Click(object sender, EventArgs e)

    {

        try

        {

            if (uscActionsControl.Prop_Action == ((int)Actions.SaveWithoutSubmitting).ToString())

            {

                SaveCompleteQIRData(true, RequestStatus.UnderInvestigation, Actions.SaveWithoutSubmitting);

                QIRInfo qirInfo = QIRController.GetQIRById(RequestID);
 

                RequestInfo requestInfo = RequestController.GetRequestById(RequestID);

                NotificationReminderController.AddNotificationReminder(1, qirInfo.ID, UserController.GetEmployeeInfo(CurrentUser.EmpID).Email,

                    ConfigurationManager.AppSettings["SavedWithoutSubmitting"], ReadEmailTemplate("SavedWithoutSubmitting.htm").Replace("[QIRNumber]", requestInfo.QIRNumber)

                    , CurrentDate.AddDays(2));

                

                ClosePage();

            }

            else if (uscActionsControl.Prop_Action == ((int)Actions.SendBack).ToString())

            {

                SaveCompleteQIRData(false, RequestStatus.ReturnedBacktoCDM, Actions.SendBack);

                QIRInfo qirInfo = QIRController.GetQIRById(RequestID);

                NotificationReminderController.DeleteNotificationReminder(1, qirInfo.ID);

                uscActionsControl.SubmitAction();

                

                ClosePage();

            }

            else if (uscActionsControl.Prop_Action == ((int)Actions.Submit).ToString())

            {

                if (uscImpInvestigation.IsValidData() == true)

                {

                    SaveCompleteQIRData(false, RequestStatus.InProgress, Actions.Submit);

                    QIRInfo qirInfo = QIRController.GetQIRById(RequestID);

                    NotificationReminderController.DeleteNotificationReminder(1, qirInfo.ID);

                    uscActionsControl.SubmitAction();

                    ClosePage();

                }

                else

                {

                    ClientScript.RegisterStartupScript(GetType(), "ImplementerSubmited", "alert('" + GetGlobalResourceObject("SABIC.QIR", "ImplementerSubmited.Text").ToString() + "');", true);

                }

            }

            else

            {

                SaveCompleteQIRData(false, RequestStatus.InProgress, Actions.Submit);

                QIRInfo qirInfo = QIRController.GetQIRById(RequestID);

                NotificationReminderController.DeleteNotificationReminder(1, qirInfo.ID);

                uscActionsControl.SubmitAction();

                ClosePage();

            }
 

        }

        catch

        {

            throw;

        }

    }

    #endregion

}

Open in new window

0
 
LVL 10

Accepted Solution

by:
jinn_hnnl earned 500 total points
ID: 22812308
Do you have problem with Delete too? Have you checked, I am not sure, but when I did it your way (using ItemTemplate) I have to supply commandArgument as well, without that it's crashed.

I have spent sometimes to read your code, and it seems to be fine. The only thing I concern about is whether the objectdatasources can understand the update argument you gave that way. (I guess they do, because when you separate them it works)...

The update might fail or doesn't act the way it is when the gridview datasource is somehow rebind accidentally. Your page is quite complicated so that all I can guess for now. Or unless I will have to spend an hour to specificly understand what's going on with each control.

My suggestion now is you should try to narrow the problem, simplify the page (minimum control) for testing purposes. If you guess the problem come from those 3 mentioned user control, reduce your page contain to that, and start to figure out what happened.

This page is pretty large content for that.

JINN
0
 
LVL 11

Author Closing Comment

by:Salim Fayad
ID: 31510217
This is what I have been doing before posting the problem here (trying to narrow down the problem).

Anway, I found the problem, it was from a 3rd party control, the "RapidSpellChecker" which was causing the problem because the code was:


btnEventDescription.Visible = false;

It must be:


btnEventDescription.ShowButton = false;



Thanks JINN for your support
0
 
LVL 10

Expert Comment

by:jinn_hnnl
ID: 22821302
Glad you worked it out

JINN ^^
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now