Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • tarekahf 215 posts 153 karma points
    Apr 23, 2010 @ 00:45
    tarekahf
    0

    Using AutoComplete Ajax Toolkit Control under Umbraco.

    I have developed a complex .NET User Control based on VS 2005 and .NET 2.0. The UC has about 5 AutoComplete Ajax Control targeted for .NET 2.0. Also, the same UC has EO.Web Grid Control and a .NET DetailsView with complete CRUD Operations, which are linked to CSLA .NET Business Objects.

    All work fine under a traditional .NET Web Application Project using VS 2005.

    Now, I am planning to deply this work under Umbraco.

    I am refering to this article:

    http://our.umbraco.org/wiki/how-tos/adding-ajaxcontroltoolkit-v3-support-to-umbraco

    Based on my understanding, there should be no problem, right ?

    There will be a problem if I am using Ajax Toolkit for VS 2008, and then I have to follow the instruction in this article.

    Tarek.

  • tarekahf 215 posts 153 karma points
    May 02, 2010 @ 15:54
    tarekahf
    0

    I am have started deploying the above mentioned work under a new fresh successful installation of Umbraco 4.0.3.

    As soon as I open the page which has the Macto/Use Control, under Umbraco, it will fail, and following is the error I get using:

    "?umbdebugshowtrace=true".

     

    Error creating usercontrol (/usercontrols/clinic/ucLabRequest.ascx)
    Could not load file or assembly 'AjaxControlToolkit, Version=1.0.20229.20821, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
      at System.Web.Compilation.AssemblyBuilder.AddBuildProvider(BuildProvider buildProvider)
      at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
      at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
      at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
      at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
      at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
      at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath)
      at System.Web.UI.TemplateControl.LoadControl(String virtualPath)
      at umbraco.macro.loadUserControl(String fileName, Hashtable attributes, Hashtable pageElements)

    Aparently, there is conflict between the AjaxControlToolkit I am using and that which is used by Umbraco.

    How I can resolve this problem ?

    Note: This is my first project which will go-live under Umbraco at work.

    Appreciate your help.

    Tarek.

  • tarekahf 215 posts 153 karma points
    May 02, 2010 @ 16:11
    tarekahf
    0

    I will add more info about the above problem.

    I tried to recompile my DLL (clinic User Controls) using the AjaxControlToolkit.dll (1.0.10920.32880) that comes with Umbraco. Compile was successful.

    Then, I tried to run the User Control under Umbraco, this time, no error, but I am getting this client JavaScript Error:

    Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    Timestamp: Sun, 2 May 2010 14:07:09 UTC

    Message: 'AjaxControlToolkit' is undefined
    Line: 339
    Char: 5
    Code: 0
    URI: http:///clinic/lab-search.aspx?

    And, the User Control is not working at all.

    Appreciate your help.

    Tarek.

  • tarekahf 215 posts 153 karma points
    May 02, 2010 @ 22:07
    tarekahf
    0

    I was able to resolve all the problems mentioned above, however, I have now another problem.

    It seems that the PostBack event is not being detected inside the Page_Load Event inside the User Control. I did debug under Umbraco, and found out that Inside the Page_Load Event, the property "Page.IsPostBack" is alwasy false. This means, everytime the User Control in run in a Post-Back Event, it will be sent as a new request.

    How I can resolve this problem ?

    Tarek. 

  • Aaron Powell 1708 posts 3046 karma points c-trib
    May 03, 2010 @ 00:35
    Aaron Powell
    0

    To solve your original problem you can probably just get away with using assemblyBinding in the web.config (http://msdn.microsoft.com/en-us/library/twy1dw1e.aspx).

    As for your current problem, not sure.

  • tarekahf 215 posts 153 karma points
    May 03, 2010 @ 09:33
    tarekahf
    0

    Not only the "IsPostBack" event is always "false", also, the "TextChanged" event for the "TextBox" Server Control (inside the UC) is not being fired at all.

    I created a code-behined for the Master Page I am using inside Umbraco, I did a test inside the "Page_Load" event of the Master Page, and I noticed that no mater what, the "IsPostBack" is alwasy "false".

    I have tested my User Control from inside a traditional Web Project Application, and it is working successfully.

    Please help.

    Tarek.

  • Fredrik Sewén 39 posts 106 karma points
    May 03, 2010 @ 11:34
    Fredrik Sewén
    0

    Hi Tarek,

    Can you post some code so we can see how you have implemented the updatepanel and textbox?

    Can you get any event to fire? Like a button-click inside the updatepanel?

    /Fredrik

  • tarekahf 215 posts 153 karma points
    May 03, 2010 @ 13:15
    tarekahf
    0

    Thank you Fredrik for the reply.

    Note: I am using the Umbraco Runway Basic Document Types and MasterPages and other samples etc to do my test.

    Let me define the problem so that it is clear:

    1. The property "IsPostBack" is alwasy false.

    2. The following events (which I tested) are not triggered on the server like "Button_Click" and "TextBox_TextChanged".

    3. The PostBack Even is triggered. I mean, if you change the TextBox, it will cause a post-back, but the "TextChanged" event will not be executed.

    The above problem will occur when:

    1. When you have a User Control Macro which has Ajax and other complicated stuff like:

    <%@ Control Language="vb" AutoEventWireup="true" CodeBehind="ucLabRequest.ascx.vb" Inherits="CSLAIDB.Library.Clinic.ucLabRequest" EnableViewState="true"  %>
    <%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    <%@ Register Assembly="Csla" Namespace="Csla.Web" TagPrefix="csla" %>

    2. Only under Umbraco.

    When I remove the complex user control and put a simple Macro User Control instead, everything works fine.

    The same complex User Control works fine under a Traditional Web Application Project.

    My guess is that using Ajax under Umbraco has caused some kind of conflict which is causing ASP.NET to misbehave.

    Appreciated your help.

     

    Here is the complete code of my Complex User Control:

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucLabRequest.ascx.vb" Inherits="CSLAIDB.Library.Clinic.ucLabRequest"  %>
    <%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    <%@ Register Assembly="Csla" Namespace="Csla.Web" TagPrefix="csla" %>
    <script language="javascript">
    function LabRequestItemsGridKeyUp() {
        //alert("The GridID is '" + theGridID + "'");
        var theGrid;
        if (event.keyCode == 46) {
            theGrid = eo_GetContainer(event.srcElement, 'Grid');
            if (theGrid) {
                if (!theGrid.getEditItem() && theGrid.getItemCount() > 0 && theGrid.getSelectedItem()) {
                    if (confirm("Are you sure you want to delete selected row ?")) {
                        theGrid.deleteItem(theGrid.getSelectedItem().getIndex());
                        GridSelectNearestItem(theGrid, theGrid.getSelectedItem().getIndex());
                    }
                }
            }
        }
    }
    function GridSelectNearestItem(theGrid, idx) {
        var i;
        var idxSelected=-1;
        if (theGrid && theGrid.getItemCount() > 0) {
            for (i=idx+1; i < theGrid.getItemCount(); i++) {
                var itemCurrent = theGrid.getItem(i);
                if (itemCurrent && !itemCurrent.isDeleted()) {
                    idxSelected = i;
                    break;
                }
            }
            if (idxSelected < 0) {
                for (i=idx; i >= 0; i--) {
                    var itemCurrent = theGrid.getItem(i);
                    if (itemCurrent && !itemCurrent.isDeleted()) {
                        idxSelected = i;
                        break;
                    }
                }
            }
        }
        if (idxSelected >=0) {
            //var curPage = theGrid.getCurrentPage();
            //theGrid.goToPage(0);
            //theGrid.goToPage(curPage);
            theGrid.selectItem(idxSelected);
            theGrid.getSelectedItem().ensureVisible();
        }
    }
    function getGridCellElm(cell) {
        var elmID;
        var theCellElm;
        elmID = cell.getGrid().getId() + "_i" + cell.getItemIndex() + "_c" + cell.getColIndex();
        var theCellElm = document.getElementById(elmID);
        return theCellElm;
    }
    var txtLabTestKeyValue = "txtLabTestKeyValue";
    function fn_be_LabTestKeyValue(cell) {
        var elmHTML;
        var elmID;
        //elmID = cell.getGrid().getId() + "_edit_" + txtLabTestKeyValue;
        elmHTML = $get("<%=txtLabTestKeyValue_ClientID()%>"); //document.getElementById(elmID);
        cell.getGrid().selectItem(cell.getItemIndex());
        elmHTML.value = cell.getValue();
        elmHTML.style.height = "15px";// = getGridCellElm(cell).style.cssText;
        setTimeout(function() {elmHTML.focus(); elmHTML.select()}, 10);
    }
    function fn_ee_LabTestKeyValue_timeout(cell) {
        cell.getGrid().editItem(cell.getItemIndex(), true)
    }
    function fn_ee_LabTestKeyValue(cell) {
        var elmHTML;
        var elmID;
        //elmID = cell.getGrid().getId() + "_edit_" + txtLabTestKeyValue;
        elmHTML = $get("<%=txtLabTestKeyValue_ClientID()%>"); //document.getElementById(elmID);
        return elmHTML.value;
    }
    function getOffset( elPrm ) { 
        var _x = 0;
        var _y = 0;
        var el = elPrm;
        while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
            _x += el.offsetLeft; // - el.scrollLeft;
            _y += el.offsetTop; // - el.scrollTop;
            if (el != elPrm) {
                _y += el.clientTop; // - el.scrollTop;
            }
            el = el.parentNode;
        }
        return { top: _y, left: _x };
    }
     
    function txtLabTestKeyValue_OnClientShown(source, eventArgs){
        //alert("OnClientShown");
        var elmComp = source.get_completionList();
    //    var theGrid = eo_GetContainer(source.get_element() , 'Grid');
    //    var elmGrid = document.getElementById(theGrid.getId());
    //    var GridOffset = getOffset(elmGrid);
    //    var GridIndex = parseInt(elmGrid.zIndex)
    //    var CompBound = $common.getLocation(elmComp);
        var myAnchor = $get("txtLabTestKeyValue_anchor")
        $common.setLocation(elmComp, $common.getLocation(myAnchor));
    //    elmComp.style.posTop = CompOffset.top;
    //    elmComp.style.posLeft = CompOffset.left;
    }
    function timeOut_txtLabTestKeyValue() {
        //Get the "anchor" position
        var e = $get("anchor_txtLabTestKeyValue");
        var b = $common.getBounds(e);
        //Move the "editor" to the same position
        //and display the editor at the same time
        e = $get("editor_txtLabTestKeyValue");
        e.style.display = "";
        $common.setLocation(e, b);
    }
    //This function is called when the cell enters edit mode.
    //We dynamically align the "editor" div to "anchor div
    //in this function
    function begin_edit_txtLabTestKeyValue(cell)
    {
        //The call must be delayed with a timer because
        //at this moment "anchor" is not visible yet
        setTimeout(timeOut_txtLabTestKeyValue, 10);
    }
    //This function is called when the cell exists
    //edit mode
    function end_edit_txtLabTestKeyValue(cell)
    {
        //Hide the editor
        var e = $get("editor_txtLabTestKeyValue");
        e.style.display = "none";
       
        //Return the new value to the Grid
        var input = $get("<%=txtLabTestKeyValue_ClientID()%>");
        return input.value;
    }
    </script>
    <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
    <div id="txtLabTestKeyValue_complList" style="z-index:1000"></div>
    <div id="divErrorLabel" class="ErrorLabel"><asp:Label ID="ErrorLabel" runat="server" /></div>
    <div runat="server" id="SearchPanel" class="ParameterList">
        <div class="ParameterItem">
            <asp:Label ID="Label2" CssClass="ParameterItemLabel" runat="server" Text="Enter Lab Req. ID:" />
            <asp:TextBox ID="txtLabRequestIDLookup"  CssClass="ParameterItemInput" runat="server" AutoPostBack="True"></asp:TextBox>
        </div>
        <div class="ButtonList">
            <asp:LinkButton ID="lnkAddRequest" CssClass="ButtonItem" runat="server">Add New Request</asp:LinkButton>
            <asp:LinkButton ID="lnkSearchLabRequest" CssClass="ButtonItem" PostBackUrl="~/LabRequestListSearch.aspx" runat="server">Search Lab Requests</asp:LinkButton>
        </div>
    </div>
    <div class="LabRequestContainer">
    <div class="LabRequest">
    <asp:DetailsView  ID="dvLabRequest" runat="server" DataSourceID="dtaLabRequest" AutoGenerateRows="False" DataKeyNames="LabRequestID" CellPadding="4" ForeColor="#333333" GridLines="None">
        <Fields>
            <asp:TemplateField HeaderText="Request ID" SortExpression="LabRequestID">
                <EditItemTemplate>
                    <asp:Label ID="lblLabRequestID" runat="server" Text='<%# Eval("LabRequestID") %>' />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:Label ID="lblLabRequestID" runat="server" Text='[auto]' />
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblLabRequestID" runat="server" Text='<%# Eval("LabRequestID") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Patient ID" SortExpression="PatientID">
                <ItemTemplate>
                    <asp:Label ID="lblPatientID" runat="server" Text='<%# Eval("PatientID") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Patient Name" SortExpression="PatientName">
                <ItemTemplate>
                    <asp:Label ID="lblPatientName" runat="server" Text='<%# Eval("PatientName") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Patient ID - Name" SortExpression="PatientIDName">
                <EditItemTemplate>
                    <asp:TextBox ID="txtPatientIDName" runat="server" Text='<%# Bind("PatientIDName") %>' />
                    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtPatientIDName"
                        ServicePath="~/MyWebService.asmx" ServiceMethod="GetStaffIDNameList" CompletionInterval="1000" CompletionSetCount="12"
                        EnableCaching="true" MinimumPrefixLength="3" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="txtPatientIDName" runat="server" Text='<%# Bind("PatientIDName") %>' />
                    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtPatientIDName"
                        ServicePath="~/MyWebService.asmx" ServiceMethod="GetStaffIDNameList" CompletionInterval="1000" CompletionSetCount="12"
                        EnableCaching="true" MinimumPrefixLength="3" />
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Technician ID" SortExpression="TechnicianID">
                <ItemTemplate>
                    <asp:Label ID="lblTechnicianID" runat="server" Text='<%# Eval("TechnicianID") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Technician Name" SortExpression="TechnicianName">
                <ItemTemplate>
                    <asp:Label ID="lblTechnicianName" runat="server" Text='<%# Eval("TechnicianName") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Technician ID - Name" SortExpression="TechnicianIDName">
                <EditItemTemplate>
                    <asp:Label ID="lblTechnicianIDName" runat="server" Text='<%# Bind("TechnicianIDName") %>' />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:Label ID="lblTechnicianIDName" runat="server" Text='<%# Bind("TechnicianIDName") %>' />
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Doctor ID" SortExpression="DoctorID">
                <ItemTemplate>
                    <asp:Label ID="lblDoctorID" runat="server" Text='<%# Eval("DoctorID") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Doctor Name" SortExpression="DoctorName">
                <ItemTemplate>
                    <asp:Label ID="lblDoctorName" runat="server" Text='<%# Eval("DoctorName") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Doctor ID - Name:" SortExpression="DoctorIDName">
                <EditItemTemplate>
                    <asp:TextBox ID="txtDoctorIDName" runat="server" Text='<%# Bind("DoctorIDName") %>' />
                    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" TargetControlID="txtDoctorIDName"
                        ServicePath="~/MyWebService.asmx" ServiceMethod="GetClinicStaffIDNameList" CompletionInterval="1000" CompletionSetCount="12"
                        EnableCaching="true" MinimumPrefixLength="3" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="txtDoctorIDName" runat="server" Text='<%# Bind("DoctorIDName") %>' />
                    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" TargetControlID="txtDoctorIDName"
                        ServicePath="~/MyWebService.asmx" ServiceMethod="GetClinicStaffIDNameList" CompletionInterval="1000" CompletionSetCount="12"
                        EnableCaching="true" MinimumPrefixLength="3" />
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField DataField="IsHealthCheck" HeaderText="Is Health Check?" SortExpression="IsHealthCheck" />
            <asp:TemplateField HeaderText="Diagnosis ID" SortExpression="DiagnosisID">
                <ItemTemplate>
                    <asp:Label ID="lblDiagnosisID" runat="server" Text='<%# Eval("DiagnosisID") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="DiagnosisDesc" SortExpression="DiagnosisDesc">
                <ItemTemplate>
                    <asp:Label ID="lblDiagnosisDesc" runat="server" Text='<%# Eval("DiagnosisDesc") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Diagnosis ID - Desc" SortExpression="DiagnosisIDDesc">
                <EditItemTemplate>
                    <asp:TextBox ID="txtDiagnosisIDDesc" runat="server" Text='<%# Bind("DiagnosisIDDesc") %>'></asp:TextBox>
                    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender3" runat="server" TargetControlID="txtDiagnosisIDDesc"
                        ServicePath="~/MyWebService.asmx" ServiceMethod="GetDiagnosisList" CompletionInterval="2000" CompletionSetCount="12"
                        EnableCaching="true" MinimumPrefixLength="1" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="txtDiagnosisIDDesc" runat="server" Text='<%# Bind("DiagnosisIDDesc") %>'></asp:TextBox>
                    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender3" runat="server" TargetControlID="txtDiagnosisIDDesc"
                        ServicePath="~/MyWebService.asmx" ServiceMethod="GetDiagnosisList" CompletionInterval="1000" CompletionSetCount="12"
                        EnableCaching="true" MinimumPrefixLength="1" />
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="DiagnosisOther" HeaderText="Diagnosis Other" SortExpression="DiagnosisOther" >
                <ControlStyle Width="300px" />
            </asp:BoundField>
            <asp:TemplateField HeaderText="Request Date (DMY)" SortExpression="LabRequestDate">
                <EditItemTemplate>
                    <asp:TextBox ID="txtLabRequestDateDMYStr" runat="server" Text='<%# Bind("LabRequestDateDMYStr") %>' Width="70px" />
                    <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtLabRequestDateDMYStr"  Format="dd/MM/yyyy"/>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="txtLabRequestDateDMYStr" runat="server" Text='<%# Bind("LabRequestDateDMYStr") %>' />
                    <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtLabRequestDateDMYStr"  Format="dd/MM/yyyy"/>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblLabRequestDateDMYStr" runat="server" Text='<%# Bind("LabRequestDateDMYStr") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField DataField="CompletedFlag" HeaderText="Is Completed?" SortExpression="CompletedFlag" />
            <asp:TemplateField HeaderText="Date Completed" SortExpression="CompletedDate">
                <EditItemTemplate>
                    <asp:Label ID="lblCompletedDate" runat="server" Text='<%# Bind("CompletedDateDMYStr") %>' />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:Label ID="lblCompletedDate" runat="server" Text='<%# Bind("CompletedDateDMYStr") %>' />
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblCompletedDate" runat="server" Text='<%# Bind("CompletedDateDMYStr") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="LabComments" HeaderText="Comments" SortExpression="LabComments" >
                <ControlStyle Height="50px" />
                <ItemStyle CssClass="LabComments" />
            </asp:BoundField>
            <asp:CommandField ShowEditButton="True" ShowInsertButton="True" ShowDeleteButton="True" />
            <asp:ButtonField CommandName="Restart" Text="Restart" />
        </Fields>
        <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
        <RowStyle ForeColor="#333333" BackColor="#F7F6F3" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#999999" />
        <EmptyDataTemplate>
            Please select a Lab Request to work with.
        </EmptyDataTemplate>
        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:DetailsView>
    </div>
    <csla:CslaDataSource ID="dtaLabRequest" runat="server" TypeAssemblyName="CSLAIDB.Library" TypeName="CSLAIDB.Library.Clinic.LabRequest"
        TypeSupportsPaging="False" TypeSupportsSorting="True">
    </csla:CslaDataSource>
    <div class="LabRequestDetails">
    <eo:grid id="gridLabItems" runat="server" BorderColor="#828790" BorderWidth="1px" ColumnHeaderAscImage="00050204" ColumnHeaderDescImage="00050205" ColumnHeaderDividerImage="00050203" ColumnHeaderHeight="24" FixedColumnCount="1" Font-Bold="False" Font-Italic="False" Font-Names="Tahoma" Font-Overline="False" Font-Size="8.75pt" Font-Strikeout="False" Font-Underline="False" GridLineColor="240, 240, 240" GridLines="Both" Height="227px" ItemHeight="19" Width="538px"
         EnableKeyboardNavigation="True" KeyField="LabRequestItemID" AllowNewItem="True"
        
    >
        <FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" />
        <ItemStyles>
            <eo:GridItemStyleSet>
                <ItemStyle CssText="background-color: white" />
                <ItemHoverStyle CssText="background-image: url(00050206); background-repeat: repeat-x" />
                <SelectedStyle CssText="background-image: url(00050207); background-repeat: repeat-x" />
                <CellStyle CssText="padding-left:8px;padding-top:2px;white-space:nowrap;" />
            </eo:GridItemStyleSet>
        </ItemStyles>
        <ColumnTemplates>
            <eo:TextBoxColumn>
                <TextBoxStyle CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 8.75pt; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; FONT-FAMILY: Tahoma" />
            </eo:TextBoxColumn>
            <eo:DateTimeColumn>
                <DatePicker ControlSkinID="None" DayCellHeight="16" DayCellWidth="19" DayHeaderFormat="FirstLetter"
                    DisabledDates="" OtherMonthDayVisible="True" SelectedDates="" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL"
                    TitleRightArrowImageUrl="DefaultSubMenuIcon">
                    <TodayStyle CssText="font-family: tahoma; font-size: 12px; border-right: #bb5503 1px solid; border-top: #bb5503 1px solid; border-left: #bb5503 1px solid; border-bottom: #bb5503 1px solid" />
                    <SelectedDayStyle CssText="font-family: tahoma; font-size: 12px; background-color: #fbe694; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                    <DisabledDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                    <PickerStyle CssText="border-bottom-color:#7f9db9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#7f9db9;border-left-style:solid;border-left-width:1px;border-right-color:#7f9db9;border-right-style:solid;border-right-width:1px;border-top-color:#7f9db9;border-top-style:solid;border-top-width:1px;font-family:Courier New;font-size:8pt;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;" />
                    <CalendarStyle CssText="background-color: white; border-right: #7f9db9 1px solid; padding-right: 4px; border-top: #7f9db9 1px solid; padding-left: 4px; font-size: 9px; padding-bottom: 4px; border-left: #7f9db9 1px solid; padding-top: 4px; border-bottom: #7f9db9 1px solid; font-family: tahoma" />
                    <TitleArrowStyle CssText="cursor:hand" />
                    <DayHoverStyle CssText="font-family: tahoma; font-size: 12px; border-right: #fbe694 1px solid; border-top: #fbe694 1px solid; border-left: #fbe694 1px solid; border-bottom: #fbe694 1px solid" />
                    <MonthStyle CssText="font-family: tahoma; font-size: 12px; margin-left: 14px; cursor: hand; margin-right: 14px" />
                    <TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:12px;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;" />
                    <OtherMonthDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                    <DayHeaderStyle CssText="font-family: tahoma; font-size: 12px; border-bottom: #aca899 1px solid" />
                    <DayStyle CssText="font-family: tahoma; font-size: 12px; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
                </DatePicker>
            </eo:DateTimeColumn>
            <eo:MaskedEditColumn>
                <MaskedEdit ControlSkinID="None" TextBoxStyle-CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; font-family:Courier New;font-size:8pt;">
                </MaskedEdit>
            </eo:MaskedEditColumn>
        </ColumnTemplates>
        <ColumnHeaderHoverStyle CssText="background-image:url('00050202');padding-left:8px;padding-top:4px;" />
        <ColumnHeaderTextStyle CssText="TEXT-ALIGN: right" />
        <Columns>
            <eo:StaticColumn DataField="LabRequestItemID" HeaderText="Item ID" Width="60">
                <CellStyle CssText="TEXT-ALIGN: center" />
            </eo:StaticColumn>
            <eo:CustomColumn ClientSideBeginEdit="fn_be_LabTestKeyValue" ClientSideEndEdit="fn_ee_LabTestKeyValue"
                DataField="LabTestKeyValue" HeaderText="Laboratory Test Details (Test ID - RefID - Catg - Test Name)"
                Width="350">
                <EditorTemplate>
                <asp:TextBox ID="txtLabTestKeyValue" Width="340" runat="server" />
                <div id="txtLabTestKeyValue_anchor" style="width:1px; height:1px;"></div>
                <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender4" TargetControlID="txtLabTestKeyValue" runat="server"
                   ServicePath="~/MyWebService.asmx" ServiceMethod="GetLabTestKeyValue" CompletionInterval="1000" CompletionSetCount="12"
                   EnableCaching="true" MinimumPrefixLength="3" OnClientShown="txtLabTestKeyValue_OnClientShown"
                    CompletionListElementID="txtLabTestKeyValue_complList"
                />
                </EditorTemplate>
            </eo:CustomColumn>
            <eo:TextBoxColumn DataField="LabTestResult" HeaderText="Result">
            </eo:TextBoxColumn>
        </Columns>
        <ColumnHeaderStyle CssText="BACKGROUND-IMAGE: url(00050201); PADDING-LEFT: 8px; PADDING-TOP: 4px" />
    </eo:grid>
    <div class="LabRequestCommands">
        <asp:Button ID="btnSaveLabItems" runat="server" Text="Save Test Result" />
        <asp:Button ID="btnTestLabReport" runat="server" Text="Lab Report" />
    </div>
    </div>
    </div>
    <csla:CslaDataSource ID="dtaLabRequestItems" runat="server" TypeAssemblyName="" TypeName="CSLAIDB.Library.Clinic.LabRequestItems, CSLAIDB.Library" TypeSupportsPaging="False" TypeSupportsSorting="False">
    </csla:CslaDataSource>

     

    Here is the CodeBehined:

     

    Imports System.Web.UI
    Namespace Clinic
        Partial Public Class ucLabRequest
            Inherits System.Web.UI.UserControl
            Private mLabRequestID As Integer
            Private mDoCreateLabRequest As Boolean = False
            Private StaffList As StaffIDNameValueList = StaffIDNameValueList.GetList()
            Protected Function txtLabTestKeyValue_ClientID() As String
                Return CType(gridLabItems.Columns(1), EO.Web.CustomColumn).EditorInstance.FindControl("txtLabTestKeyValue").ClientID
            End Function
            Public Property LabRequestID() As Integer
                Get
                    Dim theLabRequestID As Integer
                    Try
                        theLabRequestID = dvLabRequest.DataKey.Item("LabRequestID")
                        mLabRequestID = theLabRequestID
                    Catch ex As Exception
                        theLabRequestID = mLabRequestID
                    End Try
                    Return mLabRequestID
                End Get
                Set(ByVal value As Integer)
                    SearchPanel.Attributes.CssStyle.Item("display") = "none"
                    If mLabRequestID <> value Then
                        mLabRequestID = value
                        txtLabRequestIDLookup.Text = mLabRequestID.ToString()
                        mDoCreateLabRequest = False
                        dvLabRequest.DataBind()
                    End If
                End Set
            End Property
            Public Property DoCreateLabRequest() As Boolean
                Get
                    Dim result As Boolean
                    Dim theLabRequest As LabRequest
                    theLabRequest = GetLabRequest()
                    If Not theLabRequest Is Nothing Then
                        result = theLabRequest.IsNew()
                    Else
                        result = mDoCreateLabRequest
                    End If
                    Return result
                End Get
                Set(ByVal value As Boolean)
                    mDoCreateLabRequest = True
                    'dvLabRequest.DefaultMode = WebControls.DetailsViewMode.Insert
                    dvLabRequest.ChangeMode(WebControls.DetailsViewMode.Insert)
                End Set
            End Property
            Private Function GetLabRequest() As LabRequest
                Dim theLabRequest As LabRequest = Nothing
                Try
                    If TypeOf Session("BusinessObject") Is LabRequest Then
                        theLabRequest = CType(Session("BusinessObject"), LabRequest)
                    Else
                        Session("BusinessObject") = Nothing
                    End If
                Catch ex As Exception
                    Session("BusinessObject") = Nothing
                End Try
                If theLabRequest Is Nothing Then
                    ProcesstxtLabRequestIDLookup(True)
                End If
                If (mLabRequestID > 0 AndAlso theLabRequest Is Nothing) _
                    OrElse _
                   (Not theLabRequest Is Nothing AndAlso mLabRequestID > 0 AndAlso mLabRequestID <> theLabRequest.LabRequestID) _
                Then
                    theLabRequest = LabRequest.GetLabRequest(mLabRequestID)
                    Session("BusinessObject") = theLabRequest
                End If
                If (mDoCreateLabRequest AndAlso Not theLabRequest Is Nothing AndAlso Not theLabRequest.IsNew()) _
                    OrElse _
                    (mDoCreateLabRequest AndAlso theLabRequest Is Nothing) Then
                    theLabRequest = LabRequest.NewLabRequest()
                    Session("BusinessObject") = theLabRequest
                    mLabRequestID = 0
                End If
                mDoCreateLabRequest = False
                If Not theLabRequest Is Nothing Then
                    If theLabRequest.IsNew() Then
                        txtLabRequestIDLookup.Text = "[new]"
                    Else
                        txtLabRequestIDLookup.Text = theLabRequest.LabRequestID()
                    End If
                Else
                    txtLabRequestIDLookup.Text = ""
                End If
                Return theLabRequest
            End Function
            Private Function SaveLabRequest(ByVal theLabRequest As LabRequest, Optional ByVal DoRaiseErrors As Boolean = False) As Integer
                Dim rowsAffected As Integer
                Try
                    Session("BusinessObject") = theLabRequest.Save()
                    mLabRequestID = theLabRequest.LabRequestID
                    rowsAffected = 1
                    mDoCreateLabRequest = False
                Catch ex As Csla.Validation.ValidationException
                    If DoRaiseErrors Then
                        GlobalFunctions.PreserveStackTrace(ex)
                        Throw  'New Csla.Validation.ValidationException(ex.Message, ex)
                    End If
                    Dim message As New System.Text.StringBuilder
                    message.AppendFormat("{0}<br/>", ex.Message)
                    If theLabRequest.BrokenRulesCollection.Count = 1 Then
                        message.AppendFormat("* {0}: {1}", _
                          theLabRequest.BrokenRulesCollection(0).Property, _
                          theLabRequest.BrokenRulesCollection(0).Description)
                    Else
                        For Each rule As Csla.Validation.BrokenRule In _
                            theLabRequest.BrokenRulesCollection
                            message.AppendFormat( _
                              "* {0}: {1}<br/>", rule.Property, rule.Description)
                        Next
                    End If
                    Me.ErrorLabel.Text = message.ToString
                    rowsAffected = 0
                Catch ex As Csla.DataPortalException
                    If DoRaiseErrors Then
                        GlobalFunctions.PreserveStackTrace(ex)
                        Throw  ' New Csla.DataPortalException(ex.Message, ex)
                    End If
                    Me.ErrorLabel.Text = ex.BusinessException.Message
                    rowsAffected = 0
                Catch ex As Exception
                    If DoRaiseErrors Then
                        GlobalFunctions.PreserveStackTrace(ex)
                        Throw  ' New Csla.DataPortalException(ex.Message, ex)
                    End If
                    Me.ErrorLabel.Text = ex.Message
                    rowsAffected = 0
                End Try
                Return rowsAffected
            End Function
            Protected Sub dtaLabRequest_SelectObject(ByVal sender As System.Object, ByVal e As Csla.Web.SelectObjectArgs) Handles dtaLabRequest.SelectObject
                Try
                    Dim theLabRequest As LabRequest
                    theLabRequest = GetLabRequest()
                    e.BusinessObject = theLabRequest
                    If Not theLabRequest Is Nothing Then
                        gridLabItems.DataSource = theLabRequest.RequestItems
                    Else
                        gridLabItems.DataSource = Nothing
                        gridLabItems.Items.Clear()
                    End If
                    gridLabItems.DataBind()
                Catch ex As Csla.DataPortalException
                    Me.ErrorLabel.Text = ex.BusinessException.Message
                    gridLabItems.DataSource = Nothing
                    gridLabItems.Items.Clear()
                Catch ex As Exception
                    Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace
                    gridLabItems.DataSource = Nothing
                    gridLabItems.Items.Clear()
                End Try
            End Sub
            Protected Sub dtaLabRequest_UpdateObject(ByVal sender As System.Object, ByVal e As Csla.Web.UpdateObjectArgs) Handles dtaLabRequest.UpdateObject
                'Dim MyDtaSrc As Csla.Web.CslaDataSource
                Dim obj As LabRequest = GetLabRequest()
                Try
                    Csla.Data.DataMapper.Map(e.Values, obj)
                Catch ex As Csla.Validation.ValidationException
                    Me.ErrorLabel.Text = ex.Message
                Catch ex As Csla.DataPortalException
                    Me.ErrorLabel.Text = ex.BusinessException.Message
                Catch ex As eHRMDException
                    Me.ErrorLabel.Text = ex.Message
                Catch ex As Exception
                    Me.ErrorLabel.Text = ex.Message
                End Try
                e.RowsAffected = SaveLabRequest(obj)
            End Sub
            Protected Sub dtaLabRequest_InsertObject(ByVal sender As System.Object, ByVal e As Csla.Web.InsertObjectArgs) Handles dtaLabRequest.InsertObject
                Try
                    Dim obj As LabRequest = LabRequest.NewLabRequest()
                    Csla.Data.DataMapper.Map(e.Values, obj, "LabRequestId")
                    e.RowsAffected = SaveLabRequest(obj)
                Catch ex As Csla.Validation.ValidationException
                    e.RowsAffected = 0
                    Me.ErrorLabel.Text = ex.Message
                Catch ex As System.ArgumentException
                    If Not ex.InnerException Is Nothing AndAlso Not ex.InnerException.InnerException Is Nothing Then
                        e.RowsAffected = 0
                        Me.ErrorLabel.Text = ex.InnerException.InnerException.Message
                    Else
                        Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace
                    End If
                Catch ex As Csla.DataPortalException
                    e.RowsAffected = 0
                    Me.ErrorLabel.Text = ex.BusinessException.Message
                Catch ex As eHRMDException
                    e.RowsAffected = 0
                    Me.ErrorLabel.Text = ex.Message
                Catch ex As Exception
                    e.RowsAffected = 0
                    Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace
                End Try
            End Sub
            Sub ProcesstxtLabRequestIDLookup(Optional ByVal DoSkipBind As Boolean = False)
                Dim theLabRequestID As Integer
                If dvLabRequest.CurrentMode = WebControls.DetailsViewMode.ReadOnly Then
                    If IsNumeric(txtLabRequestIDLookup.Text) Then
                        theLabRequestID = Convert.ToInt32(txtLabRequestIDLookup.Text)
                    ElseIf String.IsNullOrEmpty(txtLabRequestIDLookup.Text.Trim) Then
                        ' Nothing
                        txtLabRequestIDLookup.Text = ""
                        theLabRequestID = -1
                    Else
                        Me.ErrorLabel.Text = "LabRequestID '" & txtLabRequestIDLookup.Text & "' must be numeric value."
                        txtLabRequestIDLookup.Text = ""
                        theLabRequestID = -1
                    End If
                    If LabRequestID <= 0 OrElse (theLabRequestID > 0 AndAlso LabRequestID <> theLabRequestID) Then
                        'Restart()
                        mLabRequestID = theLabRequestID
                        mDoCreateLabRequest = False
                        If Not DoSkipBind Then
                            dvLabRequest.DataBind()
                        End If
                    End If
                End If
            End Sub
            Protected Sub txtLabRequestIDLookup_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLabRequestIDLookup.TextChanged
                Try
                    ProcesstxtLabRequestIDLookup()
                Catch ex As Exception
                    Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace
                End Try
            End Sub
            Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                Dim theLabRequestID As String
                Try
                    If IsPostBack Then
                        'ProcesstxtLabRequestIDLookup()
                        Me.ErrorLabel.Text = ""
                    Else
                        theLabRequestID = Request.QueryString("LabRequestID")
                        If Not String.IsNullOrEmpty(theLabRequestID) Then
                            Me.LabRequestID = theLabRequestID
                            Response.Redirect(Page.ResolveClientUrl(Page.Request.Path))
                        End If
                    End If
                Catch ex As Exception
                    Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace
                End Try
            End Sub
            Private Sub Restart()
                Try
                    Dim dtaSrcIDSave As String
                    Session("BusinessObject") = Nothing
                    dvLabRequest.DefaultMode = WebControls.DetailsViewMode.ReadOnly
                    dvLabRequest.ChangeMode(WebControls.DetailsViewMode.ReadOnly)
                    txtLabRequestIDLookup.Text = ""
                    mLabRequestID = -1
                    dtaSrcIDSave = dvLabRequest.DataSourceID
                    dvLabRequest.DataSourceID = ""
                    dvLabRequest.DataBind()
                    dvLabRequest.DataSourceID = dtaSrcIDSave
                    RestartLabItems()
                Catch ex As Exception
                End Try
            End Sub
            Private Sub dvLabRequest_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewCommandEventArgs) Handles dvLabRequest.ItemCommand
                Dim myDV As WebControls.DetailsView
                myDV = sender
                If (e.CommandName = "Restart") Or _
                    (e.CommandName = "Cancel" And myDV.CurrentMode = WebControls.DetailsViewMode.Insert) Then
                    Restart()
                End If
            End Sub
            Private Sub dvLabRequest_ItemCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvLabRequest.ItemCreated
                Dim myDV As WebControls.DetailsView
                Dim txtLabRequestDateDMYStr As WebControls.TextBox
                myDV = sender
                If myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then
                    Dim theLabRequest As LabRequest = GetLabRequest()
                    txtLabRequestDateDMYStr = myDV.FindControl("txtLabRequestDateDMYStr")
                    If Not txtLabRequestDateDMYStr Is Nothing AndAlso Not theLabRequest Is Nothing Then
                        txtLabRequestDateDMYStr.Text = theLabRequest.LabRequestDate.ToString("dd/MM/yyyy")
                    End If
                End If
            End Sub
            Private Sub dvLabRequest_ItemDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewDeletedEventArgs) Handles dvLabRequest.ItemDeleted
                dvLabRequest.DataBind()
            End Sub
            Private Sub dvLabRequest_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles dvLabRequest.ItemInserted
                Dim myDV As WebControls.DetailsView
                myDV = sender
                If e.AffectedRows <= 0 Then
                    e.KeepInInsertMode = True
                End If
            End Sub
            Private Sub dvLabRequest_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles dvLabRequest.ItemInserting
                Dim myDV As WebControls.DetailsView
                myDV = sender
            End Sub
            Private Sub RestartLabItems()
                Session("ChangedItems") = Nothing
                Session("DeletedItems") = Nothing
                gridLabItems.DataSource = Nothing
                gridLabItems.Items.Clear()
                gridLabItems.SelectedItemIndex = -1
                gridLabItems.DataBind()
            End Sub
            Private Sub dvLabRequest_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvLabRequest.ModeChanged
                Dim myDV As WebControls.DetailsView
                myDV = sender
                If myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then
                    mDoCreateLabRequest = True
                    RestartLabItems()
                End If
            End Sub
            Private Sub dvLabRequest_ModeChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewModeEventArgs) Handles dvLabRequest.ModeChanging
                Dim myDV As WebControls.DetailsView
                Dim theLabRequest As LabRequest
                myDV = sender
                theLabRequest = GetLabRequest()
                If e.CancelingEdit AndAlso Not theLabRequest Is Nothing AndAlso theLabRequest.IsNew() Then
                    Session("BusinessObject") = Nothing
                End If
            End Sub
            Private Sub dvLabRequest_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvLabRequest.PreRender
                Dim myDV As System.Web.UI.WebControls.DetailsView
                Dim theTxtBoxWidth As WebControls.Unit = WebControls.Unit.Parse("370px")
                Dim thePatientIDNameFld As WebControls.DataControlField
                Dim txtPatientIDName As WebControls.TextBox
                Dim idxPateint As Integer
                Dim theTechnicianIDNameFld As WebControls.DataControlField
                Dim lblTechnicianIDName As WebControls.Label
                Dim idxTechnician As Integer
                Dim theDoctorIDNameFld As WebControls.DataControlField
                Dim txtDoctorIDName As WebControls.TextBox
                Dim idxDoctor As Integer
                Dim theDiagnosisIDFld As WebControls.DataControlField
                Dim txtDiagnosisIDDesc As WebControls.TextBox
                Dim idxDiagnosis As Integer
                Dim theLabCommentsFld As WebControls.DataControlField
                Dim txtLabComments As WebControls.TextBox
                Dim idxLabComments As Integer
                Dim LabCommentsCtrl As WebControls.TableCell
                myDV = sender
                Try

                    thePatientIDNameFld = GetDataControlField(myDV, "PatientIDName")
                    If Not thePatientIDNameFld Is Nothing Then
                        idxPateint = myDV.Fields.IndexOf(thePatientIDNameFld)
                        If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then
                            thePatientIDNameFld.HeaderText = "Lookup Patient ID - Name (partial match OK): "
                        Else
                            thePatientIDNameFld.HeaderText = "Patient ID - Name: "
                        End If
                    End If
                    theTechnicianIDNameFld = GetDataControlField(myDV, "TechnicianIDName")
                    If Not theTechnicianIDNameFld Is Nothing Then
                        idxTechnician = myDV.Fields.IndexOf(theTechnicianIDNameFld)
                        If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then
                            theTechnicianIDNameFld.HeaderText = "Technician ID - Name (Authenticated User): "
                        Else
                            theTechnicianIDNameFld.HeaderText = "Technician ID - Name: "
                        End If
                    End If
                    theDoctorIDNameFld = GetDataControlField(myDV, "DoctorIDName")
                    If Not theDoctorIDNameFld Is Nothing Then
                        idxDoctor = myDV.Fields.IndexOf(theDoctorIDNameFld)
                        If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then
                            theDoctorIDNameFld.HeaderText = "Lookup Doctor ID - Name (partial match OK): "
                        Else
                            theDoctorIDNameFld.HeaderText = "Doctor ID - Name: "
                        End If
                    End If
                    theDiagnosisIDFld = GetDataControlField(myDV, "DiagnosisIDDesc")
                    If Not theDiagnosisIDFld Is Nothing Then
                        idxDiagnosis = myDV.Fields.IndexOf(theDiagnosisIDFld)
                        If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then
                            theDiagnosisIDFld.HeaderText = "Lookup Diagnosis ID - Desc (partial match OK): "
                        Else
                            theDiagnosisIDFld.HeaderText = "Diagnosis ID - Desc: "
                        End If
                    End If
                    theLabCommentsFld = GetDataControlField(myDV, "LabComments")
                    If Not theDiagnosisIDFld Is Nothing Then
                        idxLabComments = myDV.Fields.IndexOf(theLabCommentsFld)
                    Else
                        idxLabComments = -1
                    End If
                    If myDV.CurrentMode = WebControls.DetailsViewMode.Edit Or myDV.CurrentMode = WebControls.DetailsViewMode.Insert Then
                        txtPatientIDName = myDV.FindControl("txtPatientIDName")
                        If Not txtPatientIDName Is Nothing Then
                            txtPatientIDName.Width = theTxtBoxWidth
                        End If
                        If idxPateint < myDV.Rows.Count Then
                            myDV.Rows(idxPateint - 1).Attributes.CssStyle.Item("display") = "none"
                            myDV.Rows(idxPateint - 2).Attributes.CssStyle.Item("display") = "none"
                        End If
                        Dim LoggedInUser = Security.GetWindowsLoginIDWeb()
                        Dim StaffItem As StaffIDNameValueList.NameValuePair
                        lblTechnicianIDName = myDV.FindControl("lblTechnicianIDName")
                        If Not lblTechnicianIDName Is Nothing Then
                            lblTechnicianIDName.Width = theTxtBoxWidth
                            StaffItem = StaffList.LookupByKey(LoggedInUser)
                            If Not StaffItem Is Nothing Then
                                lblTechnicianIDName.Text = StaffItem.Value
                            Else
                                Throw New eHRMDException("Error: Logged in user ID '" & LoggedInUser & "' was not found.")
                            End If
                        End If
                        If idxTechnician < myDV.Rows.Count Then
                            myDV.Rows(idxTechnician - 1).Attributes.CssStyle.Item("display") = "none"
                            myDV.Rows(idxTechnician - 2).Attributes.CssStyle.Item("display") = "none"
                        End If
                        txtDoctorIDName = myDV.FindControl("txtDoctorIDName")
                        If Not txtDoctorIDName Is Nothing Then
                            txtDoctorIDName.Width = theTxtBoxWidth
                        End If
                        If idxDoctor < myDV.Rows.Count Then
                            myDV.Rows(idxDoctor - 1).Attributes.CssStyle.Item("display") = "none"
                            myDV.Rows(idxDoctor - 2).Attributes.CssStyle.Item("display") = "none"
                        End If
                        txtDiagnosisIDDesc = myDV.FindControl("txtDiagnosisIDDesc")
                        If Not txtDiagnosisIDDesc Is Nothing Then
                            txtDiagnosisIDDesc.Width = theTxtBoxWidth
                        End If
                        If idxDiagnosis < myDV.Rows.Count Then
                            myDV.Rows(idxDiagnosis - 1).Attributes.CssStyle.Item("display") = "none"
                            myDV.Rows(idxDiagnosis - 2).Attributes.CssStyle.Item("display") = "none"
                        End If
                        If Not theLabCommentsFld Is Nothing Then
                            txtLabComments = myDV.Rows(idxLabComments).Cells(1).Controls(0)
                            txtLabComments.TextMode = WebControls.TextBoxMode.MultiLine
                            txtLabComments.Width = theTxtBoxWidth
                        End If
                    ElseIf myDV.CurrentMode = System.Web.UI.WebControls.DetailsViewMode.ReadOnly Then
                        If idxPateint < myDV.Rows.Count Then
                            myDV.Rows(idxPateint).Attributes.CssStyle.Item("display") = "none"
                        End If
                        If idxTechnician < myDV.Rows.Count Then
                            myDV.Rows(idxTechnician).Attributes.CssStyle.Item("display") = "none"
                        End If
                        If idxDoctor < myDV.Rows.Count Then
                            myDV.Rows(idxDoctor).Attributes.CssStyle.Item("display") = "none"
                        End If
                        If idxDiagnosis < myDV.Rows.Count Then
                            myDV.Rows(idxDiagnosis).Attributes.CssStyle.Item("display") = "none"
                        End If
                        Dim newDiv As HtmlControls.HtmlGenericControl
                        If idxLabComments >= 0 And idxLabComments < myDV.Rows.Count Then
                            LabCommentsCtrl = myDV.Rows(idxLabComments).Cells(1)
                            newDiv = New HtmlControls.HtmlGenericControl("div")
                            newDiv.InnerHtml = LabCommentsCtrl.Text
                            LabCommentsCtrl.Text = ""
                            LabCommentsCtrl.Controls.Add(newDiv)
                        End If
                    End If
                Catch ex As Exception
                    myDV.ChangeMode(WebControls.DetailsViewMode.ReadOnly)
                    Me.ErrorLabel.Text = ex.Message & "<br>" & ex.StackTrace
                End Try

            End Sub

            Protected Sub lnkAddRequest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkAddRequest.Click
                DoCreateLabRequest = True
                RestartLabItems()
            End Sub
            Protected Sub dtaLabRequest_DeleteObject(ByVal sender As System.Object, ByVal e As Csla.Web.DeleteObjectArgs) Handles dtaLabRequest.DeleteObject
                Try
                    LabRequest.DeleteLabRequest(e.Keys("LabRequestID"))
                    Session("BusinessObject") = Nothing
                    txtLabRequestIDLookup.Text = ""
                    mLabRequestID = 0
                    e.RowsAffected = 1
                Catch ex As Csla.DataPortalException
                    Restart()
                    Me.ErrorLabel.Text = ex.BusinessException.Message
                    e.RowsAffected = 0
                Catch ex As Exception
                    Restart()
                    Me.ErrorLabel.Text = ex.Message
                    e.RowsAffected = 0
                End Try
            End Sub
            Protected Sub dtaLabRequestItems_SelectObject(ByVal sender As System.Object, ByVal e As Csla.Web.SelectObjectArgs) Handles dtaLabRequestItems.SelectObject
                Dim theLabRequest As LabRequest
                theLabRequest = GetLabRequest()
                If theLabRequest Is Nothing Then
                    e.BusinessObject = Nothing
                Else
                    e.BusinessObject = theLabRequest.RequestItems
                End If

            End Sub
            Private Sub gridLabItems_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridLabItems.DataBinding
                Dim myGrid As EO.Web.Grid
                myGrid = sender
            End Sub
            Private Sub gridLabItems_ItemAdded(ByVal sender As Object, ByVal e As EO.Web.GridItemEventArgs) Handles gridLabItems.ItemAdded
                Dim myGrid As EO.Web.Grid
                myGrid = sender
            End Sub
            Protected Sub gridLabItems_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gridLabItems.Load
                Dim myGrid As EO.Web.Grid
                myGrid = sender
                myGrid.Attributes.Item("onkeyup") = "LabRequestItemsGridKeyUp()"
            End Sub
            Private Sub gridLabItems_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridLabItems.PreRender
                Dim myGrid As EO.Web.Grid
                myGrid = sender
            End Sub
            Protected Sub dtaLabRequestItems_UpdateObject(ByVal sender As System.Object, ByVal e As Csla.Web.UpdateObjectArgs) Handles dtaLabRequestItems.UpdateObject
                Dim myDtaSrc As Csla.Web.CslaDataSource
                myDtaSrc = sender
            End Sub
            Public Sub ApplyGridChanges(ByVal theLabRequest As LabRequest)
                Dim theLabItems As LabRequestItems
                Dim theLabItem As LabRequestItem
                Dim theGridItems As EO.Web.GridItem() = Nothing
                Dim theChangedItemsArrList As List(Of EO.Web.GridItem) = New List(Of EO.Web.GridItem)
                Dim theChangedItems As EO.Web.GridItem() = Nothing
                Dim theDeletedItemsArrList As List(Of EO.Web.GridItem) = New List(Of EO.Web.GridItem)
                Dim theDeletedItems As EO.Web.GridItem() = Nothing
                Try
                    Dim itm As EO.Web.GridItem
                    Dim IsItmFound As Boolean = False
                    Dim itmIdx As Integer = 0
                    Dim itm2Idx As Integer = 0
                    Dim itm2 As EO.Web.GridItem
                    ' Get the failed Changed Items in the last post back
                    theChangedItems = CType(Session("ChangedItems"), EO.Web.GridItem())
                    If Not theChangedItems Is Nothing Then
                        theChangedItemsArrList.AddRange(theChangedItems)
                    End If
                    ' Get the failed Deleted Items in the last post back
                    theDeletedItems = CType(Session("DeletedItems"), EO.Web.GridItem())
                    If Not theDeletedItems Is Nothing Then
                        theDeletedItemsArrList.AddRange(theDeletedItems)
                    End If
                    ' Get copy of new deleted items from the Grid.
                    For Each itm In gridLabItems.DeletedItems
                        theDeletedItemsArrList.Add(itm)
                    Next
                    ' Remove Duplicates of Changed Items by comparing each item 
                    ' with the new changed items
                    For Each itm In gridLabItems.ChangedItems
                        If Not String.IsNullOrEmpty(itm.Key) Then
                            itm2Idx = 0
                            IsItmFound = False
                            For Each itm2 In theChangedItemsArrList.ToArray()
                                If itm.Key.ToString = itm2.Key.ToString Then
                                    ' Same Key Value? Remove it !
                                    theChangedItemsArrList.Remove(itm2)
                                    IsItmFound = True
                                    Exit For
                                End If
                                itm2Idx += 1
                            Next
                            If IsItmFound Then
                                theChangedItemsArrList.Insert(itm2Idx, itm)
                            Else
                                theChangedItemsArrList.Add(itm)
                            End If
                        Else
                            Throw New Exception("Unexpected error: Null key value for Changed Item of LabKeyValue '" + itm.Cells("1").Value + "'.")
                        End If
                    Next
                    ' Insert the new Added Items from the Grid to the list
                    ' Generate Dummy Key Value
                    itmIdx = -1
                    Dim tempKey As Integer
                    For Each itm In gridLabItems.Items
                        ' these are the item that failed to be added in a previous post-back
                        If Not String.IsNullOrEmpty(itm.Key) AndAlso itm.Key.ToString.IndexOf("N*") >= 0 Then
                            ' get greatest value
                            tempKey = Convert.ToInt16(itm.Key.ToString.Substring(itm.Key.ToString.IndexOf("N*") + 2))
                            If tempKey > itmIdx Then
                                itmIdx = tempKey
                            End If
                        End If
                    Next
                    If itmIdx < 0 Then
                        itmIdx = 1
                    Else
                        itmIdx += 1
                    End If
                    For Each itm In gridLabItems.AddedItems
                        itm.Key = "N*" & itmIdx
                        itm.Cells(0).Value = itm.Key
                        theChangedItemsArrList.Add(itm)
                        itmIdx += 1
                    Next
                    Session("ChangedItems") = Nothing
                    Session("DeletedItems") = Nothing
                    Try
                        ' Update the changed items New Array List to Database.
                        ' In case of any error, save the changed items for next post-back
                        If Not theLabRequest Is Nothing Then
                            theLabItems = theLabRequest.RequestItems
                            If Not theLabItems Is Nothing Then
                                ' Apply Database Updates for Changed Items
                                Dim updItem As EO.Web.GridItem
                                Dim ItemKey As String
                                Dim theLabTestKeyValue As String
                                Dim theLabResult As String
                                ' Process Deletions of for deleted items that were saved to Database
                                theDeletedItems = theDeletedItemsArrList.ToArray()
                                For Each updItem In theDeletedItems
                                    ItemKey = updItem.Key.ToString
                                    ' first search for lab item by Key
                                    If ItemKey.IndexOf("N*") < 0 Then
                                        theLabItem = theLabItems.FindItem(Convert.ToInt16(ItemKey))
                                        If Not theLabItem Is Nothing Then
                                            ' found ? Mark for deletion.
                                            theLabItems.Remove(theLabItem)
                                            theDeletedItemsArrList.Remove(updItem)
                                        Else 'no problem
                                        End If
                                    End If
                                Next
                                ' Process Updates and Inserts
                                theChangedItems = theChangedItemsArrList.ToArray()
                                For Each updItem In theChangedItems
                                    ItemKey = updItem.Key.ToString
                                    If ItemKey.IndexOf("N*") < 0 Then
                                        theLabItem = theLabItems.FindItem(Convert.ToInt16(ItemKey))
                                    Else
                                        theLabItem = Nothing
                                    End If
                                    If Not theLabItem Is Nothing Then
                                        ' Update
                                        theLabItem.LabTestKeyValue = updItem.Cells("LabTestKeyValue").Value
                                        theLabItem.LabTestResult = updItem.Cells("LabTestResult").Value
                                    Else
                                        ' Insert
                                        theLabTestKeyValue = updItem.Cells("LabTestKeyValue").Value
                                        theLabResult = updItem.Cells("LabTestResult").Value
                                        theLabRequest.RequestItems.AddLabRequestItem(theLabTestKeyValue, theLabResult)
                                        theChangedItemsArrList.Remove(updItem)
                                    End If
                                Next
                                ' Process Deletions of items that were deleted from the grid
                                theDeletedItems = theDeletedItemsArrList.ToArray()
                                For Each updItem In theDeletedItems
                                    If Not String.IsNullOrEmpty(updItem.Key) Then
                                        ItemKey = updItem.Key.ToString
                                        ' if this is a new item, then search by LabTestKeyValue.
                                        theLabItem = theLabItems.FindItemByKeyValue(updItem.Cells("LabTestKeyValue").Value)
                                        If Not theLabItem Is Nothing Then
                                            ' found ? Mark for deletion.
                                            If theLabItem.IsNew() Then
                                                theLabItems.Remove(theLabItem)
                                            End If
                                        Else
                                        End If
                                    End If
                                    ' in any case, remove this deleted item from the saved array list.
                                    theDeletedItemsArrList.Remove(updItem)
                                Next
                            End If
                        End If
                        SaveLabRequest(theLabRequest, True)
                        gridLabItems.DataSource = theLabRequest.RequestItems
                        gridLabItems.DataBind()
                    Catch ex As Exception
                        If theChangedItemsArrList.Count > 0 Then
                            Session("ChangedItems") = CType(theChangedItemsArrList.ToArray(), EO.Web.GridItem())
                        Else
                            Session("ChangedItems") = Nothing
                        End If
                        If theDeletedItemsArrList.Count > 0 Then
                            Session("DeletedItems") = CType(theDeletedItemsArrList.ToArray(), EO.Web.GridItem())
                        Else
                            Session("DeletedItems") = Nothing
                        End If
                        Me.ErrorLabel.Text = ex.Message
                    End Try
                Catch ex As Exception
                    '
                    ' Failed during saving of the post-back changed/deleted items ?
                    ' Clear the chached items and reset the grid.
                    '
                    Session("ChangedItems") = Nothing
                    gridLabItems.DataSource = theLabRequest.RequestItems
                    gridLabItems.DataBind() ' to Make sure the Grid is Synchronized with the Datasource.
                    Me.ErrorLabel.Text = "Unexpected Error while saving the new changed/deleted items for next post-back. All changes will be lost. See error details below:<br/>" & ex.Message & "<br/>" & ex.StackTrace
                End Try
            End Sub
            Protected Sub btnSaveLabItems_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveLabItems.Click
                Dim theLabRequest As LabRequest
                theLabRequest = GetLabRequest()
                ApplyGridChanges(theLabRequest)
            End Sub
            Protected Sub btnTestLabReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTestLabReport.Click
                Dim theLabRequest As LabRequest
                Dim theLabReport As LabReport01PDF
                theLabRequest = GetLabRequest()
                theLabReport = New LabReport01PDF(theLabRequest.LabRequestID)
                Response.Clear()
                theLabReport.Render(Response)
                Response.End()
            End Sub
        End Class
    End Namespace

     

  • Fredrik Sewén 39 posts 106 karma points
    May 03, 2010 @ 13:53
    Fredrik Sewén
    0

    Who, that is a complex control ;-)

    I can't see any obvious errors. How about creating a new macro, and dissect the complex control and add part by part to the new control? That way, you'll know where it starts to break. Than perhaps we can narrow down what the problem seems to be. 

    /Fredrik

     

  • tarekahf 215 posts 153 karma points
    May 03, 2010 @ 14:09
    tarekahf
    0

    Fredrik,

    Great I dea ... this is the only way. I will do that .... the only problem is that the Clinic Staff have committed a schedule to start the with new system.

    By the way, this Clinic system was originally developed under DNN, and I decided to re-write it based on Ajax and User Controls to allow faster Data Entry. Under DNN, it was very sloooooow ... cause the user have to navigate among 5 screens to do simple updates. If I hope I can deploy it under Umbraco.

    If I am unable to nail down the problem, I will have to use the Tranditional Web Application Project instead of Umbraco.

    Tarek.

  • Fredrik Sewén 39 posts 106 karma points
    May 03, 2010 @ 14:28
    Fredrik Sewén
    0

    Well, using a traditional Web Application Project is a short-term solution. If you get it working under Umbraco it will save you a lot of time with future development. 

    Try taking baby-steps, examine where the problem occurs and keep us posted. We will try to assist you from there. 

  • tarekahf 215 posts 153 karma points
    May 03, 2010 @ 15:19
    tarekahf
    0

    Fredrik,

    The baby steps worked ! I can't be more happy. I know the source of the problem, but I am thinking how to resolve it.

    Here is the culprit ASP Control:

     

     

    <asp:LinkButton ID="lnkSearchLabRequest" CssClass="ButtonItem" PostBackUrl="~/LabRequestListSearch.aspx" runat="server">Search Lab Requests</asp:LinkButton

    >

     

    If I delete the above <asp:LinkButton> Control, it workes, and I see the events are being executed and "IsPostBack" is working fine.

    Also, if I keep this control and set the value of "PostBackUrl" to empty string, it works.

    If I put any value for "PostBackUrl" the problem is back again. Even if I put a valid URL or even "#" !!!! This button will navigate from the Laboratory Entry Screen back to the Search Screen.

    Do you think this is a bug in Umbraco ? Should I report it ?

    Let me move now to finding a workaround:

    Can you help me please ?

    I have 2 main screens in this application. Each Screen is a Macro User Control.

    Screen 1: Search Laboratory Requests. Here the user will use extermly flexible criteria to locate the Lab Request. When he clicks on an item in the ASP GridView, he must move to the Labroratory Request Entry Screen. Here is the code-behined for SelectedIndexChanged:

            Protected Sub gvLabRequestList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gvLabRequestList.SelectedIndexChanged
                Dim myGV As System.Web.UI.WebControls.GridView
                myGV = sender
                Response.Redirect("LabRequestTest.aspx?LabRequestID=" & Me.SelectedLabRequestID)
            End Sub

    As you can see, I am hard-coding the URL of the second screen in the Traditional Web Application Project.

    Screen 2: Laboratory Request Entry Screen. In this screen, the user will maintain the request entry and all its details. He can click on "Search Laboratory Request" to move back to the search screen, as you have seen in the link button above. But, I am hard-coding the URL.

    Now, in Umbraco, what is the best way to implement this kind of navigation ?

    Tarek.

  • Fredrik Sewén 39 posts 106 karma points
    May 03, 2010 @ 15:37
    Fredrik Sewén
    0

    To get dynamic links to a Node in Umbraco you can use:

    umbraco.library.NiceUrl(int NodeId)

    If the only purpose of that button is to link back to the search-page I would use an asp:HyperLink instead. That would give a cleaner html. But it shouldn't really matter.

    Before you post it as a bug in Umbraco I would make certain what the button with postbackurl is acctually doing, using fiddler or something alike. It should try to post to a new page. I'm not really sure why it returns to the same page. That sounds fishy.

    /Fredrik

  • tarekahf 215 posts 153 karma points
    May 03, 2010 @ 15:43
    tarekahf
    0

    The "postbackurl" of the ASP Link Button does not have any code-behind. If I remove the hard-coded URL, it will work.

    I will try to implement the final solution tomorrow.

    Tarek.

  • tarekahf 215 posts 153 karma points
    May 04, 2010 @ 16:55
    tarekahf
    0

    All is OK now.

    Tarek.

  • Eric Herlitz 97 posts 129 karma points
    Sep 30, 2011 @ 23:13
    Eric Herlitz
    0

    This can be solved by disabling any control using PostBackUrl since they mess with postbacks in general in Umbraco

Please Sign in or register to post replies

Write your reply to:

Draft