locked
Place the selected text(link button text) from a gridview into a repeater textbox RRS feed

  • Question

  • User1182587605 posted

    Hi All,

    I need to place the link button text inside a gridview as the text of active textbox which is in the repeater. Please check my code below and help me what I need to do.

    Both my controls are in the same page.

    <div class="modal" id="itemslistmodal" tabindex="-1">
                                                                <div class="modal-dialog" style="max-height: 350px; width: 900px;">
                                                                    <div class="modal-content">
                                                                        <div class="modal-header">
                                                                            <button class="close" data-dismiss="modal">&times;</button>
                                                                            <h4 class="modal-title">Items list</h4>
                                                                        </div>
                                                                        <div class="modal-body">                                                                       
                                                                            <div class="input-group" style="float: right">
                                                                                <asp:TextBox runat="server" ID="txtSearch" Width="350" Style="margin: 0px auto;" class="form-control" placeholder="Search"></asp:TextBox>                                                                           
                                                                                <asp:Button runat="server" ID="btnsearch" Text="Search" class="btn btn-primary" Style="text-align: center" Width="100" OnClick="txtSearch_TextChanged" TabIndex="1000"></asp:Button>
                                                                            </div>
                                                                           
                                                                            <div id="Div1" runat="server" style="max-height: 350px; width: 900px; overflow: auto;" align="center">
                                                                                <br />
                                                                                <asp:GridView ID="GridView1" OnRowCommand="GridView1_RowCommand" runat="server" AutoGenerateColumns="false" Font-Size="Small" HeaderStyle-BackColor="#3C5569" HeaderStyle-ForeColor="White">
                                                                                    
                                                                                    <Columns>                                                                                    <asp:TemplateField HeaderText="ItemNumber">
                                                                                            <ItemTemplate>                                                                                           
                                                                                                <asp:LinkButton ID="lnkbtnItemNumber" CommandName="Select" CommandArgument='<%# Eval("ItemNumber") %>' runat="server" Text='<%# Eval("ItemNumber") %>' OnClick="lnkbtnItemNumber_Click" ItemStyle-Width="80" DataNavigateUrlFields="ItemNumber"></asp:LinkButton>
                                                                                            </ItemTemplate>
                                                                                        </asp:TemplateField>
                                                                                        <asp:BoundField DataField="Variation" HeaderText="Variation" ItemStyle-Width="280" />
                                                                                        <asp:BoundField DataField="ItemName" HeaderText="ItemName" ItemStyle-Width="250" />
                                                                                        <asp:BoundField DataField="SellingPrice" HeaderText="Cost($)" ItemStyle-Width="80" />
                                                                                    </Columns>
                                                                                </asp:GridView>
                                                                            </div>
                                                                        </div>
                                                                        <div class="modal-footer">
                                                                            <button class="btn btn-primary" data-dismiss="modal">Close</button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>

    Repeater code is:

    <asp:Repeater ID="Repeater2" OnItemCommand="Repeater2_ItemCommand" OnItemDataBound="Repeater2_ItemDataBound" runat="server">
                                                                <ItemTemplate>
                                                                    <tr>                                                                  
                                                                        <td>                                                                        
                                                                            <asp:TextBox ID="ItemId" onfocus="moveup(this);" class="form-control" runat="server" AutoPostBack="False" Width="130" Text=''></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="variation" onfocus="moveup(this);" class="form-control" AutoPostBack="true" OnTextChanged="ItemId_TextChanged" runat="server" Text='' Width="200"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="ItemName" class="form-control" runat="server" Text='' ReadOnly="True" Width="300"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Qnty" onfocus="moveup(this);" runat="server" Text='' OnTextChanged="Qnty_TextChanged" AutoPostBack="true" Width="100" Style="text-align: right" class="form-control" TabIndex="2"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Cost" class="form-control" runat="server" Text='' Width="100" Style="text-align: right" ReadOnly="True"> </asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Value" runat="server" class="form-control" Text='' Width="150" Placeholder="AutoCalculated" Style="text-align: right" ReadOnly="True" TabIndex="0"></asp:TextBox>
                                                                        </td>                                                                   
                                                                    </tr>
                                                                </ItemTemplate>
                                                                <FooterTemplate>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label13" Width="130" Style="text-align: center" Text="" Font-Size="Small"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label29" Width="200" Style="text-align: center" Text="" Font-Size="Small"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label runat="server" ID="Label14" Style="text-align: right" class="" Text="" Width="300" Font-Size="Small"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label runat="server" ID="Label15" Style="text-align: right" class="" Text="" Width="100" Font-Size="Small"></asp:Label></td>
                                                                        <td>
                            <asp:Button runat="server" ID="Button2" Text="Save" class="btn btn-dark-blue" Style="text-align: center" Width="100" CommandName="UpdateDatabase" OnClick="Button2_Click" TabIndex="1000"></asp:Button>
                                                                        </td>
                                                                    </tr>
                                                                </FooterTemplate>
                                                            </asp:Repeater>

    The C# code I have written is:

     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if(e.CommandName=="Select")
                {               
                    string selecteditem = Convert.ToString(e.CommandArgument);               
                    ((TextBox)Repeater2.Items[0].FindControl("ItemId")).Text = selecteditem;
                    ((TextBox)Repeater2.Items[0].FindControl("ItemId")).Focus();
                }
            }

    Now, When I click the imagebutton, The popup closes but page remains grey and the imagebutton text does not come into the repeater's textbox. Please modify my code so that it works...

    Thanks,

    Deepak

    Monday, July 10, 2017 10:20 AM

Answers

  • User-271186128 posted

    Hi Deepak,

    Since you didn't provide the SQL database, I modify the columns using my data table. 

    In the GridView_RowCommand event, please debug your code and make sure you could find the TextBox control from the Repeater control. 

    If you can't find the TextBox, in the SetInitialRow method, you could add a row to the DataTable, then bind it to the Repeater Control.

    Besides, since, you are using ViewState to store the DataTable, in the GridView_RowCommand event, after get the selected item from GridView, you could add new data row to the DataTable and re-bind the Repeater control.

    code as below:

            protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "Select")
                {
    string selecteditem = Convert.ToString(e.CommandArgument); //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "closeModal();", true); ////If you are using the following code, please make sure the repeater control contains items. //((TextBox)item.FindControl("ItemId")).Text = selecteditem; //((TextBox)Repeater2.Items[0].FindControl("ItemId")).Text = selecteditem; //((TextBox)Repeater2.Items[0].FindControl("ItemId")).Focus(); //get the datatable DataTable dt = (DataTable)ViewState["CurrentTable"]; //add new item to datatable dt.Rows.Add(selecteditem, "", "", "", "", ""); ViewState["CurrentTable"] = dt; //rebind the repeater control. Repeater2.DataSource = dt; Repeater2.DataBind(); //update the UpdatePanel. InvyUpdatePanel.Update(); //close the modal popup mask. ScriptManager.RegisterStartupScript(this, GetType(), "Close Modal Popup", "Closepopup();", true); } }

    Code in JavaScript:

             function Closepopup() {
                        $(".modal-backdrop").remove();
                        $("#itemslistmodal").modal('hide');
    
                    }

    Then, after that you could call the UpdatePanel.Update() method to update the repeater content. And call the close modal method to close the Modal Popup mask.

    Best regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 19, 2017 6:46 AM

All replies

  • User-271186128 posted

    Hello Deepak,

    The code is fine and works for me, I suggest you add a breakpoint to check if the RowCommand event would fire and check if it successfully gets the textbox in the event.
    If you still fail to get it work, I suggest you share your current whole code here.

    Here is my test code:

           <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#itemslistmodal">Open</button>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TestDbConnectionString %>" SelectCommand="SELECT ItemNumber FROM [T1]"></asp:SqlDataSource>
            <div class="modal" id="itemslistmodal" tabindex="-1">
            <div class="modal-dialog" style="max-height: 350px; width: 900px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Items list</h4>
                    </div>
                    <div class="modal-body">                                                                                                                                        
                        <div id="Div1" runat="server" style="max-height: 350px; width: 900px; overflow: auto;" align="center">
                            <br />
                            <asp:GridView ID="GridView2" DataSourceID="SqlDataSource2" OnRowCommand="GridView2_RowCommand" runat="server" AutoGenerateColumns="false" Font-Size="Small" HeaderStyle-BackColor="#3C5569" HeaderStyle-ForeColor="White">                                                                                
                                <Columns> 
                                    <asp:TemplateField HeaderText="ItemNumber">
                                       <ItemTemplate>                                                                                           
                                            <asp:LinkButton ID="lnkbtnItemNumber" CommandName="Select" CommandArgument='<%# Eval("ItemNumber") %>' runat="server" Text='<%# Eval("ItemNumber") %>' ItemStyle-Width="80" DataNavigateUrlFields="ItemNumber"></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-primary" data-dismiss="modal">Close</button>
                    </div>
                </div>
            </div>
        </div>
            <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource3">
            <ItemTemplate>
                <table>
                <tr>                                                                    
                    <td>                                                                        
                        <asp:TextBox ID="ItemId" class="form-control" runat="server" AutoPostBack="False" Width="130" Text=''></asp:TextBox>
                    </td>                                                          
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                <tr>
                    <td>
        <asp:Button runat="server" ID="Button2" Text="Save" class="btn btn-dark-blue" Style="text-align: center" Width="100" CommandName="UpdateDatabase" TabIndex="1000"></asp:Button>
                    </td>
                </tr>
                </table>
            </FooterTemplate>
        </asp:Repeater>
            <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:TestDbConnectionString %>" SelectCommand="SELECT A FROM [T4]"></asp:SqlDataSource>

    code behind:

            protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "Select")
                {
                    string selecteditem = Convert.ToString(e.CommandArgument);
                    ((TextBox)Repeater2.Items[0].FindControl("ItemId")).Text = selecteditem;
                    ((TextBox)Repeater2.Items[0].FindControl("ItemId")).Focus();
                }
            }

    The output as below:

    Best regards,
    Dillion

    Tuesday, July 11, 2017 7:38 AM
  • User1182587605 posted

    Hi Dillion,

    Thanks. I have failed to get this working.. Please check my full page code and help me do the needful. This is a lot of code. Please place a debugger:

    <section id="content">
            <!-- content -->
            <form class="form-horizontal custom-form row" id="form1" runat="server">
                <div id="divContainer">
                    <div class="cost-transfer-block">
                        <!-- cost-transfer-block -->
                        <div class="container-fluid">
                            <div class="row">
                                <div>
                                    <h2>Special Order Entry</h2>
                                    <div class="col-md-5 cst-brd-right ">
                                       <%-- <div class="col-md-8 ">--%>
                                        <div class="form-group">
                                            <asp:Label runat="server" class="control-label col-md-4" ID="lblSplorder" Text="Spl. Order No.#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:"></asp:Label>
                                            <div class="col-md-8">
                                                <div class="input-group">
                                                    <asp:TextBox runat="server" class="form-control" ID="txtSplorder" OnTextChanged="TxtInventoryNumber_TextChanged" AutoPostBack="true" placeholder="Spl Order No"></asp:TextBox>
                                                    <span class="input-group-addon" id="listViewDiv">
                                                        <asp:ImageButton runat="server" href="javascript:;" class="dropdown-toggle" ID="Imagebutton2" data-toggle="dropdown" OnInit="Imagebutton2_Init" AccessKey="i" src="../images/icon-add-on-3.png" alt=""></asp:ImageButton>
                                                        <asp:ListView ID="ListView2" runat="server">
                                                            <LayoutTemplate>
                                                                <ul class="dropdown-menu dropdown-menu-right" id="ul" runat="server">
                                                                    <%--onclick="ul_Click"--%>
                                                                    <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                                                                </ul>
                                                            </LayoutTemplate>
                                                            <ItemTemplate>
                                                                <li>
                                                                    <a href="javascript:;"><%# DataBinder.Eval(Container.DataItem, "SplOrd_Num") %></a>
                                                                </li>
                                                            </ItemTemplate>
                                                            <EmptyDataTemplate>
                                                                <p>Nothing here.</p>
                                                            </EmptyDataTemplate>
                                                        </asp:ListView>
                                                    </span>
                                                </div>
                                            </div>
                                        </div>
                                        </br>
                                            <div class="form-group">
                                                <asp:Label runat="server" class="control-label col-md-4" ID="lblStore" Text="Store# &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:"></asp:Label>
                                                <div class="col-md-8">
                                                    <div class="input-group">
                                                        <asp:TextBox runat="server" class="form-control" ID="txtStore" AutoPostBack="true" OnTextChanged="txtStore_TextChanged" placeholder="Number"></asp:TextBox>
                                                        <%--<div id="listViewDiv">--%>
                                                        <span class="input-group-addon" id="listViewDiv1">
                                                            <%--<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" ><img src="images/icon-add-on-3.png" alt="" /></a>
                                                            <ul class="dropdown-menu dropdown-menu-right">
                                                              <li><a href="javascript:;">Action</a></li>
                                                              <li><a href="javascript:;">Another action</a></li>
                                                              <li><a href="javascript:;">Something else here</a></li>
                                                            </ul>--%>
                                                            <asp:ImageButton runat="server" href="javascript:;" class="dropdown-toggle" ID="imgbtnSite" data-toggle="dropdown" OnInit="imgbtnSite_Init" src="../images/icon-add-on-3.png" alt=""></asp:ImageButton>
                                                            <asp:ListView ID="ListView1" runat="server">
                                                                <LayoutTemplate>
                                                                    <ul class="dropdown-menu dropdown-menu-right" id="ul" runat="server">                                                                    
                                                                    <%--onclick="ul_Click"--%>
                                                                        <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                                                                    </ul>
                                                                </LayoutTemplate>
                                                                <ItemTemplate>
                                                                    <li>
                                                                        <a href="javascript:;"><%# DataBinder.Eval(Container.DataItem, "r1") %></a>
                                                                    </li>
                                                                </ItemTemplate>
                                                                <EmptyDataTemplate>
                                                                    <p>Nothing here.</p>
                                                                </EmptyDataTemplate>
                                                            </asp:ListView>
                                                        </span>
                                                        <%--   <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" Style="top: 98px; left: 367px; ; height: 26px; width: 162px" ErrorMessage="StoreID Required" ControlToValidate="txtStore"></asp:RequiredFieldValidator>       --%>
                                                    </div>
                                                </div>
                                            </div>
                                        <%--</div>--%>
                                        <%--                                    <div class="col-md-12">--%>
                                        <br />
                                        <div class="form-group">
                                            <asp:Label runat="server" ID="lblDate" class="control-label col-md-4" Text="Date &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:"></asp:Label>
                                            <div class="col-md-8 transferdate">
                                                <div class="input-group">
                                                    <asp:TextBox ID="txtDate" runat="server" class="form-control" placeholder="Enter Date"></asp:TextBox>
                                                    <span class="input-group-addon">
                                                        <asp:LinkButton runat="server" ID="lnkinvydate" OnClick="lnkinvydate_Click" class="" AccessKey="e"><img src="../images/icon-add-on-2-date.png" alt="" /></asp:LinkButton></span>
                                                    <div id="caldiv">
                                                        <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged" Visible="false" BackColor="White"></asp:Calendar>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-5">
                                        <div class="form-group">
                                            <asp:Label runat="server" ID="lbllocation" Text="Location   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :" class="control-label col-sm-12 col-md-3"></asp:Label>
                                            <div class="col-sm-5 col-md-8">
                                                <asp:TextBox runat="server" AutoPostBack="False" class="form-control" ID="txtLocation" placeholder="Location"></asp:TextBox>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <asp:Label runat="server" ID="lblnote" Text="Order Notes  &nbsp; :" class="col-sm-12 col-md-3"></asp:Label>
                                            <div class="col-sm-5 col-md-8">
                                                <asp:TextBox runat="server" AutoPostBack="False" class="form-control" ID="txtnote" placeholder="Order Notes" TextMode="MultiLine"></asp:TextBox>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-4 col-lg-2">
                                    <div class="number-of-item-block">
                                        <div class="row">
                                            <div class="col-md-12">
                                                <asp:Label runat="server" ID="lblNoofItems" Text="No. of Item Rows"></asp:Label>
                                            </div>
                                            <div class="col-md-12">
                                                <asp:TextBox runat="server" class="form-control" ID="txtNoofItems" Style="text-align: right" placeholder="#"></asp:TextBox>
                                                <asp:LinkButton runat="server" ID="LnkBtnNoofItems" class="btn btn-dark-blue" OnClick="LnkBtnNoofItems_Click1"><i class="glyphicon glyphicon-plus"></i></asp:LinkButton>
                                                <div class="row">
                                                    <div class="col-md-6"></div>
                                                    <div class="col-md-6"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="btns-group">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <asp:Button runat="server" ID="BtnTopClear" Text="Clear" class="btn btn-dark-blue" align="center" Width="100" OnClick="BtnTopClear_Click"></asp:Button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /cost-transfer-block -->
                    <div class="center-block">
                        <asp:Label CssClass="col-lg-12 col-md-12 col-sm-12" ID="lblMessage" runat="server"></asp:Label>
                    </div>
                    <div class="white-table-view-block ">
                        <!-- white-table-view-block -->
                        <div class="container-fluid">
                            <!-- container-fluid -->
                            <div class="row">
                                <!-- row -->
                                <div class="col-md-12">
                                    <span style="float: right;"><a href="javascript:;">
                                        <img src="../images/icon-print.png" alt="" width="20" onclick="JavaScript:PrintData('divContainer');" /></a>&nbsp;&nbsp;&nbsp;<input type="button" value="PRINT" style="font-size: 13px;" onclick="JavaScript:PrintData('divContainer');"></span>
                                    <h2>cost calculation</h2>
                                    <table>
                                        <tr>
                                            <span>
                                                <td>
                                                    <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="ItemNo1" Style="text-align: left" Width="115" Text="Item Number" Font-Size="Small"></asp:Label>
                                                    <asp:ImageButton runat="server" OnClientClick="javascript:return false;" href="javascript:;" class="dropdown-toggle" ID="btnShowPopup" data-toggle="modal" src="../images/icon-add-on-3.png" data-target="#itemslistmodal"></asp:ImageButton>
                                                    <asp:ScriptManager ID="ScriptManager2" runat="server"></asp:ScriptManager>
                                                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                                        <ContentTemplate>
                                                            <div class="modal" id="itemslistmodal" tabindex="-1">
                                                                <div class="modal-dialog" style="max-height: 350px; width: 900px;">
                                                                    <div class="modal-content">
                                                                        <div class="modal-header">
                                                                            <button class="close" data-dismiss="modal">&times;</button>
                                                                            <h4 class="modal-title">Items list</h4>
                                                                        </div>
                                                                        <div class="modal-body">
                                                                            <%--<asp:Label runat="server" ID="lblSearchItemID" class="control-label col-sm-12" Text="Search"></asp:Label>--%>
                                                                            <div class="input-group" style="float: right">
                                                                                <asp:TextBox runat="server" ID="txtSearch" Width="350" Style="margin: 0px auto;" class="form-control" placeholder="Search"></asp:TextBox>
                                                                                <%-- OnTextChanged="txtSearch_TextChanged" AutoPostBack="true"--%>
                                                                                <asp:Button runat="server" ID="btnsearch" Text="Search" class="btn btn-primary" Style="text-align: center" Width="100" OnClick="txtSearch_TextChanged" TabIndex="1000"></asp:Button>
                                                                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                            </div>
                                                                            <%-- <asp:Button runat="server" ID="btnSearch" Text="search" OnClick="btnSearch_Click"/>     --%>
                                                                            <div id="Div1" runat="server" style="max-height: 350px; width: 900px; overflow: auto;" align="center">
                                                                                <br />
                                                                                <asp:GridView ID="GridView1" OnRowCommand="GridView1_RowCommand" runat="server" AutoGenerateColumns="false" Font-Size="Small" HeaderStyle-BackColor="#3C5569" HeaderStyle-ForeColor="White">
                                                                                    <%--DataSourceID="GridDataSource">--%>
                                                                                    <Columns>                                                                                    
                                                                                        <%--<asp:hyperlinkfield DataTextField="ItemNumber" HeaderText="ItemNumber" ItemStyle-Width="80" DataNavigateUrlFields="ItemNumber" DataNavigateUrlFormatString="~/PRJ_SpecialOrder.aspx?ItemNumber={0}"/>                                                                                    --%>
                                                                                        <asp:TemplateField HeaderText="ItemNumber">
                                                                                            <ItemTemplate>
                                                                                                <%--<asp:HyperLink runat="server" ID="ItemNumber" Text='<%# Eval("ItemNumber") %>' HeaderText="ItemNumber" ItemStyle-Width="80" DataNavigateUrlFields="ItemNumber"></asp:HyperLink>--%>
                                                                                                <asp:LinkButton ID="lnkbtnItemNumber" CommandName="Select" CommandArgument='<%# Eval("ItemNumber") %>' runat="server" Text='<%# Eval("ItemNumber") %>' OnClick="lnkbtnItemNumber_Click" ItemStyle-Width="80" DataNavigateUrlFields="ItemNumber"></asp:LinkButton>
                                                                                            </ItemTemplate>
                                                                                        </asp:TemplateField>
                                                                                        <asp:BoundField DataField="Variation" HeaderText="Variation" ItemStyle-Width="280" />
                                                                                        <asp:BoundField DataField="ItemName" HeaderText="ItemName" ItemStyle-Width="250" />
                                                                                        <asp:BoundField DataField="SellingPrice" HeaderText="Cost($)" ItemStyle-Width="80" />
                                                                                    </Columns>
                                                                                </asp:GridView>
                                                                            </div>
                                                                        </div>
                                                                        <div class="modal-footer">
                                                                            <button class="btn btn-primary" data-dismiss="modal">Close</button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </ContentTemplate>
                                                    </asp:UpdatePanel>
                                                </td>
                                                <td>
                                                    <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label28" Style="text-align: left" Width="80" Text="Variation" Font-Size="Small"></asp:Label>
                                                    <asp:ImageButton runat="server" OnClientClick="javascript:return false;" href="javascript:;" class="dropdown-toggle" ID="ImageButton3" data-toggle="modal" src="../images/icon-add-on-3.png" data-target="#itemslistmodal1"></asp:ImageButton>
                                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <%--<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>--%>
                                                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                                        <ContentTemplate>
                                                            <div class="modal" id="itemslistmodal1" tabindex="-1">
                                                                <div class="modal-dialog" style="max-height: 350px; width: 900px;">
                                                                    <div class="modal-content">
                                                                        <div class="modal-header">
                                                                            <button class="close" data-dismiss="modal">&times;</button>
                                                                            <h4 class="modal-title">Items list</h4>
                                                                        </div>
                                                                        <div class="modal-body">
                                                                            <%--<asp:Label runat="server" ID="lblSearchItemID" class="control-label col-sm-12" Text="Search"></asp:Label>--%>
                                                                            <div class="input-group" style="float: right">
                                                                                <asp:TextBox runat="server" ID="txtsearch1" Width="350" Style="margin: 0px auto;" class="form-control" placeholder="Search"></asp:TextBox>
                                                                                <%-- OnTextChanged="txtSearch_TextChanged" AutoPostBack="true"--%>
                                                                                <asp:Button runat="server" ID="Button3" Text="Search" class="btn btn-primary" Style="text-align: center" Width="100" OnClick="TextBox1_TextChanged" TabIndex="1000"></asp:Button>
                                                                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                            </div>
                                                                            <br />
                                                                            <%-- <asp:Button runat="server" ID="btnSearch" Text="search" OnClick="btnSearch_Click"/>     --%>
                                                                            <div id="Div2" runat="server" style="max-height: 350px; width: 900px; overflow: auto;" align="center">
                                                                                <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" Font-Size="Small" HeaderStyle-BackColor="#3C5569" HeaderStyle-ForeColor="White">
                                                                                    <%--DataSourceID="GridDataSource">--%>
                                                                                    <Columns>
                                                                                        <asp:BoundField DataField="ItemNumber" HeaderText="ItemNumber" ItemStyle-Width="80" />
                                                                                        <asp:Hyperlinkfield DataTextField="Variation" HeaderText="Variation" ItemStyle-Width="280" DataNavigateUrlFields="Variation" DataNavigateUrlFormatString="~/PRJ_SpecialOrder.aspx?Variation={0}" />
                                                                                        <asp:BoundField DataField="ItemName" HeaderText="ItemName" ItemStyle-Width="250" />
                                                                                        <asp:BoundField DataField="SellingPrice" HeaderText="Cost($)" ItemStyle-Width="80" />
                                                                                    </Columns>
                                                                                </asp:GridView>
                                                                            </div>
                                                                        </div>
                                                                        <div class="modal-footer">
                                                                            <button class="btn btn-primary" data-dismiss="modal">Close</button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </ContentTemplate>
                                                    </asp:UpdatePanel>
                                                </td>
                                                <td>
                                                    <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label11" Style="text-align: left" Width="280" Text="&nbsp;&nbsp;&nbsp;&nbsp;Description" Font-Size="Small"></asp:Label></td>
                                                <td>
                                                    <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label21" Style="text-align: right" Width="120" Text="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Quantity" Font-Size="Small"></asp:Label></td>                                            
                                                <td>
                                                    <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label31" Style="text-align: right" Width="110" Text="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cost ($)" Font-Size="Small"></asp:Label></td>                                            
                                                <td>
                                                    <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label41" Style="text-align: right" Width="145" Text="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Value($)" Font-Size="Small"></asp:Label></td>
                                                <td>&nbsp;</td>
                                            </span>
                                        </tr>
                                    </table>
                                    <div class="table-responsive">
                                        <table>
                                            <tr>
                                                <%--<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>--%>
                                                <td class="style9">
                                                    <asp:UpdatePanel runat="server" ID="InvyUpdatePanel" UpdateMode="Conditional" CssClass="col-md-12">
                                                        <ContentTemplate>
                                                            <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
                                                                <ItemTemplate>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:TextBox ID="TxtItemid" Text='<%# Eval("ItemNumber")%>' Visible='<%# Eval("ItemNumber") != "" %>' class="form-control" runat="server" Width="130" ReadOnly="True"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="TxtVariation" Text='<%# Eval("Variation")%>' Visible='<%# Eval("ItemNumber") != "" %>' class="form-control" runat="server" Width="200" ReadOnly="True"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="TxtitemName" class="form-control" Visible='<%# Eval("ItemNumber") != "" %>' runat="server" Text='<%# Eval("ItemName")%>' Width="300" ReadOnly="True"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Txtqty" runat="server" Text='<%# Eval("Qnty")%>' Width="100" Style="text-align: right" Visible='<%# Eval("ItemNumber") != "" %>' class="form-control" ReadOnly="True"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Txtcost" class="form-control" Style="text-align: right" Visible='<%# Eval("ItemNumber") != "" %>' runat="server" Text='<%# Eval("Price")%>' Width="100" ReadOnly="True"> </asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Txttotal" runat="server" Visible='<%# Eval("ItemNumber") != "" %>' Style="text-align: right" class="form-control" Width="150" Text='<%# Eval("CalVal")%>' ReadOnly="True"></asp:TextBox>
                                                                        </td>
                                                                        <td>&nbsp&nbsp&nbsp
                                                                        </td>
                                                                        <td>
                                                                            <asp:ImageButton runat="server" class="delet-icon" ID="Imagebutton1" CommandName="DeleteRow" OnClick="imgbtndelete_Click" Visible='<%# Eval("ItemNumber") != "" %>' src="../images/icon-delete.png"></asp:ImageButton>
    
                                                                        </td>                                                                    
                                                                    </tr>
                                                                </ItemTemplate>
                                                            </asp:Repeater>
                                                            <%--<footerTemplate>--%>
                                                            <asp:Repeater ID="Repeater2" OnItemCommand="Repeater2_ItemCommand" OnItemDataBound="Repeater2_ItemDataBound" runat="server">
                                                                <ItemTemplate>
                                                                    <tr>                                                                  
                                                                        <td>
                                                                            <%-- <asp:DropDownList Id="ddlItemId" OnSelectedIndexChanged="ddlItemId_SelectedIndexChanged"  AppendDataBoundItems="true" AutoPostBack="true"  class="form-control" runat="server"  Width="150" TabIndex="1"><asp:ListItem>-Select ItemId-</asp:ListItem> </asp:DropDownList>--%>
                                                                            <asp:TextBox ID="ItemId" onfocus="moveup(this);" class="form-control" runat="server" AutoPostBack="False" Width="130" Text=''></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="variation" onfocus="moveup(this);" class="form-control" AutoPostBack="true" OnTextChanged="ItemId_TextChanged" runat="server" Text='' Width="200"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="ItemName" class="form-control" runat="server" Text='' ReadOnly="True" Width="300"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Qnty" onfocus="moveup(this);" runat="server" Text='' OnTextChanged="Qnty_TextChanged" AutoPostBack="true" Width="100" Style="text-align: right" class="form-control" TabIndex="2"></asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Cost" class="form-control" runat="server" Text='' Width="100" Style="text-align: right" ReadOnly="True"> </asp:TextBox>
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Value" runat="server" class="form-control" Text='' Width="150" Placeholder="AutoCalculated" Style="text-align: right" ReadOnly="True" TabIndex="0"></asp:TextBox>
                                                                        </td>                                                                   
                                                                    </tr>
                                                                </ItemTemplate>
                                                                <FooterTemplate>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label13" Width="130" Style="text-align: center" Text="" Font-Size="Small"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label29" Width="200" Style="text-align: center" Text="" Font-Size="Small"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label runat="server" ID="Label14" Style="text-align: right" class="" Text="" Width="300" Font-Size="Small"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label runat="server" ID="Label15" Style="text-align: right" class="" Text="" Width="100" Font-Size="Small"></asp:Label></td>
                                                                        <td>
                                                                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:Button runat="server" ID="Button2" Text="Save" class="btn btn-dark-blue" Style="text-align: center" Width="100" CommandName="UpdateDatabase" OnClick="Button2_Click" TabIndex="1000"></asp:Button>
                                                                        </td>
                                                                    </tr>
                                                                </FooterTemplate>
                                                            </asp:Repeater>                                                        
                                                            <asp:Repeater ID="Repeater3" OnItemCommand="Repeater3_ItemCommand" OnItemCreated="Repeater3_ItemCreated" OnItemDataBound="Repeater3_ItemDataBound" runat="server">
    
                                                                <HeaderTemplate>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="ItemNo" Style="text-align: left" Width="130" Text="Item Number" Font-Size="Small"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Variation" Style="text-align: left" Width="200" Text="Variation" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label1" Style="text-align: left" Width="300" Text="Description" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label2" Style="text-align: right" Width="100" Text="Quantity" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label3" Style="text-align: right" Width="100" Text="Cost ($)" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label4" Style="text-align: right" Width="150" Text="Value ($)" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>&nbsp;</td>
    
                                                                    </tr>
                                                                    <br>
                                                                </HeaderTemplate>
                                                                <ItemTemplate>
                                                                    <tr>
                                                                        <td>
                                                                            <%-- <asp:DropDownList Id="ddlItemId" OnSelectedIndexChanged="ddlItemId_SelectedIndexChanged1" AutoPostBack="true"  class="form-control" runat="server" AppendDataBoundItems="true"  Width="150"> <asp:ListItem>-Select ItemId-</asp:ListItem></asp:DropDownList>--%>
    
                                                                            <asp:TextBox ID="ItemId" onfocus="moveup(this);" class="form-control" runat="server" AutoPostBack="false" Width="130" Text=''></asp:TextBox>
    
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="variation" onfocus="moveup(this);" AutoPostBack="true" class="form-control" OnTextChanged="ItemId_TextChanged1" runat="server" Text='' ReadOnly="False" Width="200"></asp:TextBox>
    
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="ItemName" class="form-control" runat="server" Text='' ReadOnly="True" Width="300"></asp:TextBox>
    
                                                                        </td>
    
                                                                        <td>
    
                                                                            <asp:TextBox ID="Qnty" onfocus="moveup(this);" runat="server" Text='' Width="100" AutoPostBack="true" Style="text-align: right" OnTextChanged="Qnty_TextChanged1" class="form-control" TabIndex="1"></asp:TextBox>
    
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Cost" class="form-control" runat="server" Text='' Width="100" Style="text-align: right" ReadOnly="True"> </asp:TextBox>
    
                                                                        </td>
                                                                        <td>
                                                                            <asp:TextBox ID="Value" runat="server" class="form-control" Text='' Width="150" Placeholder="AutoCalculated" Style="text-align: right" ReadOnly="True" TabIndex="3"></asp:TextBox>
    
                                                                        </td>                                                                   
                                                                    </tr>
                                                                </ItemTemplate>
                                                                <FooterTemplate>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label13" Width="130" Style="text-align: center" Text="" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>
                                                                            <asp:Label runat="server" ID="Label10" Style="text-align: right" class="" Text="" Width="200" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>
                                                                            <asp:Label runat="server" ID="Label17" Style="text-align: right" class="" Text="" Width="300" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>
                                                                            <asp:Label runat="server" ID="Label15" Style="text-align: right" class="" Text="" Width="100" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>
                                                                            <asp:Label runat="server" ID="Label16" Style="text-align: right" class="" Text="" Width="100" Font-Size="Small"></asp:Label></td>
    
                                                                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    
    
                            <%--<asp:button runat="server" ID="Button2" Text="Insert" class="btn btn-dark-blue"  CommandName = "UpdateDatabase"  OnClick="Button2_Click" ></asp:button>--%>
    
                                                                            <asp:Button runat="server" ID="Button1" Text="Save" class="btn btn-dark-blue" OnClick="Button1_Click" Width="100" CommandName="Update" TabIndex="1001"></asp:Button>
    
                                                                        </td>
                                                                    </tr>
                                                                </FooterTemplate>
                                                            </asp:Repeater>
                                                        </ContentTemplate>
                                                    </asp:UpdatePanel>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="Label7" Width="130" Style="text-align: center" Text="" Font-Size="Small"></asp:Label></td>
                                                <td>
                                                    <asp:Label runat="server" ID="Label8" Style="text-align: right" class="" Text="" Width="200" Font-Size="Small"></asp:Label></td>
                                                <td>
                                                    <asp:Label runat="server" ID="Label30" Style="text-align: right" class="" Text="" Width="300" Font-Size="Small"></asp:Label></td>
                                                <td>
                                                <td>
                                                    <asp:Label runat="server" class="" ID="Label10" Style="text-align: right" Width="100" Text="" Font-Size="Small"></asp:Label></td>
                                                <td>
                                                    <asp:Label runat="server" class="" ID="Label9" Style="text-align: right" Width="100" Text="" Font-Size="Small"></asp:Label></td>
                                                <td>
                                                <td>
                                                    <asp:Label runat="server" class="" ID="Label12" Style="text-align: right" Width="150" Text="" Font-Size="Small"></asp:Label></td>                                     </tr>
    
                                            <tr>
    
                                                <td>
                                                    <asp:Label runat="server" class="control-label col-sm-3 col-md-3 col-lg-3" ID="lbl1" Width="130" Style="text-align: center" Text="" Font-Size="Small"></asp:Label>
                                                </td>
                                                <td>
                                                    <asp:Label runat="server" ID="Label32" Style="text-align: right" class="" Text="" Width="200" Font-Size="Small"></asp:Label></td>
                                                <td>
                                                    <asp:Label runat="server" ID="Label5" Style="text-align: right" class="" Text="Total Quantity:&nbsp;&nbsp;" Width="300" Font-Size="Small"></asp:Label></td>
    
                                                <%--<td>Total Qty:</td>--%>
    
                                                <td>
                                                    <asp:TextBox runat="server" class="form-control" Width="100" placeholder="No. Of Item" ID="txtTotalQuantity" Style="text-align: right" ReadOnly="true" /></td>
                                                <td>
                                                    <asp:Label runat="server" class="" ID="Label6" Style="text-align: right" Width="100" Text="Total Value ($):&nbsp;&nbsp;" Font-Size="Small"></asp:Label></td>
                                                <%--<td>Total Value ($):</td>--%>
                                                <td>
                                                    <asp:TextBox runat="server" class="form-control" Width="150" Style="text-align: right" ReadOnly="true" placeholder="$" ID="txtTotalValue" /></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <div><span style="float: right;"><a href="javascript:;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="../images/icon-print.png" alt="" width="20" onclick="JavaScript:PrintData('divContainer');" /></a>&nbsp;&nbsp;&nbsp;<input type="button" value="PRINT" style="font-size: 13px;" onclick="JavaScript:PrintData('divContainer');"></span></div>
                                    <div class="center-block">
                                        <asp:Label CssClass="col-lg-12 col-md-12 col-sm-12" ID="lblMessage2" runat="server" Text=""></asp:Label>
                                    </div>
                                </div>
                            </div>
                            <br>
                            <br>
                            <br>
                            <div class="gray-btn-row clearfix">
                                <div class="btns-group" id="listViewdiv4">
                                    <asp:Button runat="server" ID="btnclear" Text="Clear" class="btn btn-dark-blue" Width="100" OnClick="btnclear_Click" AccessKey="c"></asp:Button>
                                </div>                          
                            </div>
                        </div>
                    </div>
                </div>           
                <script type="text/javascript">
    
                    $(function () {
                        $("#Qnty").keydown(function (e) {                        
                            if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||                           
                                (e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) ||                          
                                (e.keyCode >= 35 && e.keyCode <= 40)) {                           
                                return;
                            }
                            
                            if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
                                $(this).effect("highlight", {}, 50);
                                e.preventDefault();
                            }
                        });
                    });
    
                    $(function () {
                        $("#Qnty").blur(function () {
                            alert($(this).val());
                            var value = parseInt($(this).val());
                            var check = Number.isInteger(value);
                            if (check == true) {
                                alert("if this value is integer: " + check);
                                if (value > 0) {
                                    alert("This value is a positive integer!");
                                    $(".textvalue").val("");
                                }
                                else {
                                    alert("This value isn't a positive integer!");
                                }
                            }
                            else {
                                alert("This value is not a number type!");
                            }
                        });
                    });
    
                    function openModal() {
                        $(".modal-backdrop").remove();
                        $("#itemslistmodal").modal('show');
                    }
    
                    function openModal1() {
                        $(".modal-backdrop").remove();
                        $("#itemslistmodal1").modal('show');
                    }
    
                    function closeModal() {
                        $(".modal-backdrop").remove();
                        $("#itemslistmodal").modal('hide');
                    }
    
                    function closeModal1() {
                        $(".modal-backdrop").remove();
                        $("#itemslistmodal1").modal('hide');
                    }
                </script>
    
                <script type="text/javascript">
                    function PrintData(container) {
                        $("#itemslistmodal").modal().hide();
                        $('#itemslistmodal').modal('hide');
                        $('#listViewdiv').hide();
                        $("#itemslistmodal1").modal().hide();
                        $('#itemslistmodal1').modal('hide');
                        $('#listViewdiv1').hide();
                        document.getElementById('listViewDiv').style.display = "none";
                        document.getElementById('listViewDiv1').style.display = "none";
    
                        var printContent = document.getElementById(container);                    
                        var windowUrl = 'about:blank';
                        var uniqueId = new Date();
                        var windowName = 'Print' + uniqueId.getTime();
                        var printWindow = window.open(windowUrl, windowName, 'height=400,width=800');
    
                        printWindow.document.write(printContent.innerHTML);
                        printWindow.document.close();
    
                        printWindow.focus();
                        printWindow.print();
                        printWindow.close();
                        document.getElementById('listViewDiv').style.display = "block";
                        document.getElementById('listViewDiv1').style.display = "block";
    
                    }
    
                    function moveup(x) {
                        $(window).scrollTop($("#" + x.id).offset().top);
                    }
                </script>           
            </form>
        </section>

    Tuesday, July 11, 2017 9:39 AM
  • User1182587605 posted

    The cs code for the page is:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;
    
    namespace Projections
    {
        public partial class PRJ_SpecialOrder : System.Web.UI.Page
        {
            string ConString = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
            protected void Page_Load(object sender, EventArgs e)
            {
    
                Session["tabs"] = 0;
                Repeater1.Visible = false;
    
                if (txtSplorder.Text == "")
                {
                    string SQL_LstInvyNum = "";
                    SQL_LstInvyNum = "PJ_Special_Order_Select_LastjobIdfrom_PJ_LastJobID";
                    SqlConnection conn = new SqlConnection(ConString);
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    SqlDataReader ResCmd;
                    SqlCommand SelCmd = new SqlCommand(SQL_LstInvyNum, conn);
                    SelCmd.CommandType = CommandType.StoredProcedure;
    
    
                    ResCmd = SelCmd.ExecuteReader();
                    string tmpInvy = "";
                    if (ResCmd.Read())
                    {
                        tmpInvy = Convert.ToString(ResCmd["LastJobID"]);
                        txtSplorder.Text = tmpInvy;
                        txtDate.Text = DateTime.Now.ToString("MM-dd-yyyy");
                    }
                    ResCmd.Close();
                    conn.Close();
                    //Now Update the table IC_ControlNum with the current Cost Inventory Number
    
                    if (!IsPostBack)
                    {
                        string newTNumber = txtSplorder.Text;
                        int splordernum = Convert.ToInt32(newTNumber);
                        string SQLUpdtTNum = "";
    
                        string SQL_vfy = "";
    
                        SQL_vfy = "PJ_Special_Order_T_SplOrd_Num_select";
    
                        if (conn.State == ConnectionState.Closed)
                        {
                            conn.Open();
                        }
                        SqlDataReader Rd;
                        SqlCommand Cmd = new SqlCommand(SQL_vfy, conn);
                        Cmd.CommandType = CommandType.StoredProcedure;
                        Cmd.Parameters.AddWithValue("@SplOrd", splordernum);
                        Rd = Cmd.ExecuteReader();
                        if (Rd.Read())
                        {
                            Rd.Close();
                            newTNumber = txtSplorder.Text;
                            int numValTNum = Int32.Parse(newTNumber);
                            int lastjob = Convert.ToInt32(newTNumber);   
                            SQLUpdtTNum = "PJ_Special_Order_Update_LastjobIdfrom_PJ_LastJobID";
                            SqlCommand cmd = new SqlCommand(SQLUpdtTNum, conn);
                            if (conn.State == ConnectionState.Closed)
                            {
                                conn.Open();
                            }
                            cmd.CommandType = CommandType.StoredProcedure;
    
                            cmd.Parameters.AddWithValue("@lastJOB", splordernum);
                            int temp = cmd.ExecuteNonQuery();
                            txtTotalQuantity.Text = "";
                            txtTotalValue.Text = "";
                            conn.Close();
                        }
                        this.BindGrid();
                    }
                }
            }
            private void BindGrid()
            {
                SqlConnection con;
                DataSet ds;
                string ConString, CmdString;
                ConString = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
                con = new SqlConnection(ConString);
                CmdString = "PJ_Special_Order_select_from_PJ_Item_M";
                ds = new DataSet();
                SqlCommand cmd = new SqlCommand(CmdString, con);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adpt = new SqlDataAdapter();
                adpt.SelectCommand = cmd;
                adpt.Fill(ds);
    
                DataView dv = ds.Tables[0].DefaultView;
                DataView dv2 = ds.Tables[0].DefaultView;
    
                GridView1.DataSource = dv;
                GridView1.DataBind();
    
                GridView2.DataSource = dv2;
                GridView2.DataBind();
            }  
            protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
            {
                Calendar1.Visible = true;
            }
            protected void Calendar1_SelectionChanged(object sender, EventArgs e)
            {
                txtDate.Text = Calendar1.SelectedDate.ToString("MM-dd-yyyy");
                //you could get Calendar selected date using the following code
                //Calendar1.SelectedDate.
                Calendar1.Visible = false;
            }
            protected void LnkBtnNoofItems_Click(object sender, EventArgs e)
            {
    
            }
            protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
            {
                //fetching data
                if (e.CommandName == "AddRow")
                {
                    GetData();
                    dt.Rows.Add("", "", "", "", "");
                    Repeater1.DataSource = dt;
                    Repeater1.DataBind();
                    return;
                }
                if (e.CommandName == "DeleteRow")
                {
                    string SQLDel = "";
                    string SplOrd_Num = txtSplorder.Text;
                    int newSplOrd_Num = Convert.ToInt32(SplOrd_Num);
                    string newItemNumber = ((TextBox)e.Item.FindControl("TxtItemid")).Text;
                    string newvariation = ((TextBox)e.Item.FindControl("TxtVariation")).Text;
                    // Delete row
                    SqlConnection conn = new SqlConnection(ConString);
                    SqlCommand cmd = new SqlCommand("PJ_Specialorder_TDelete ", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@newSplOrd_Num", newSplOrd_Num);
                    cmd.Parameters.AddWithValue("@newItemNumber", newItemNumber);
                    cmd.Parameters.AddWithValue("@newvariation", newvariation);
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    int temp = cmd.ExecuteNonQuery();
                    conn.Close();
                }
                Repeater1.Visible = true;
                GetData();
                if (dt.Rows.Count != 0)
                {
                    dt.Rows.Add("", "", "", "", "", "");
                    Repeater1.DataSource = dt;
                    Repeater1.DataBind();
                    Repeater2.Visible = false;
                    Repeater3.Visible = false;
                    Repeater1.Visible = true;
                    lblMessage.Text = "";
                    lblMessage.CssClass = "";
                    lblMessage2.Text = "";
                    lblMessage2.CssClass = "";
                }
                else
                {
                    dt.Rows.Add("", "", "", "", "", "");
                    Repeater1.DataSource = dt;
                    Repeater1.DataBind();
                    Repeater2.Visible = false;
                    Repeater3.Visible = false;
                    Repeater1.Visible = false;
                    lblMessage.Text = "";
                    lblMessage.CssClass = "";
                    lblMessage2.Text = "";
                    lblMessage2.CssClass = "";
                }
            }
            protected System.Data.DataTable dt = null;
            void GetData()
            {            
                string temp;
                int splorder;
                if ((txtSplorder.Text == null) || (txtSplorder.Text == ""))
                {
                    temp = " ";
                    splorder = 0;
                }
                else
                {
                    temp = txtSplorder.Text;
                    splorder = Convert.ToInt32(temp);
                }
                
                string ConString = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
                SqlConnection conn = new SqlConnection(ConString);
                conn.Open();
                System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select  ItemNumber, Variation, ItemName, Cast(Qty as varchar(5)) Qnty, Price, Cast((Qty*(Cast(Price as decimal(14,2)))) as varchar(10))CalVal from PJ_Special_Order_T where  SplOrd_Num =" + splorder + "", conn);
                
                dt = new System.Data.DataTable();
                try
                {                
                    da.Fill(dt);
                }
                catch (Exception ex)
                {
                    lblMessage.CssClass = "alert alert-warning";
                    lblMessage.Text = "Msg 001: Please enter numeric values for Quantity and Cost";
                }
                conn.Close();
                conn.Dispose();           
                string SQLtotal;
                SQLtotal = "select SUM(Qty) as TotalQty, cast(SUM(CAST(Qty as decimal(14, 4)) * cast(Price as decimal(14, 4))) as decimal(14,2)) as Total from PJ_Special_Order_T where SplOrd_Num = " + splorder + "";
                SqlConnection con = new SqlConnection(ConString);
               
                SqlDataReader RestCmd;
                SqlCommand SeltCmd = new SqlCommand(SQLtotal, con);
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                if (txtSplorder.Text != "")
                {     
                    RestCmd = SeltCmd.ExecuteReader();
                    if (RestCmd.Read())
                    {
                        txtTotalValue.Text = Convert.ToString(RestCmd["Total"]);
                        txtTotalQuantity.Text = Convert.ToString(RestCmd["TotalQty"]);
                    }
                }
                con.Close();
                con.Dispose();
            }
            protected void Page_PreRender(object sender, EventArgs e)
            {            
                if (IsPostBack)
                {
                    WebControl ctrl = GetPostBackControl() as WebControl;
                    if (ctrl != null && !SetNextFocus(Controls, ctrl.TabIndex + 1)) { ctrl.Focus(); }
                }           
                if (!IsPostBack)
                {
    
                }
                else
                {
                    if (Repeater3.Visible == true)
                    {
                        Repeater1.Visible = true;
                    }
                }
            }
            protected void Imagebutton2_Init(object sender, EventArgs e)
            {
                SqlConnection con = new SqlConnection(ConString);
                string com = "  Select distinct SplOrd_Num from PJ_Special_Order_T  order by SplOrd_Num desc";
                SqlDataAdapter adpt = new SqlDataAdapter(com, con);
                DataTable dt = new DataTable();           
                adpt.Fill(dt);
                this.ListView2.DataSource = dt;
                this.ListView2.DataBind();
            }
            protected void imgbtnSite_Init(object sender, EventArgs e)
            {
                SqlConnection con = new SqlConnection(ConString);
                string com = "select distinct CAST (Store_Number as int)as r1 from  PJ_Location_M order by r1 asc";
                SqlDataAdapter adpt = new SqlDataAdapter(com, con);
                DataTable dt = new DataTable();            
                adpt.Fill(dt);
                this.ListView1.DataSource = dt;
                this.ListView1.DataBind();
            }
            protected void lnkinvydate_Click(object sender, EventArgs e)
            {
                Calendar1.Visible = true;
            }       
            protected System.Data.DataTable dc = null;
            
            private void SetInitialRow()
            {
                DataTable dt = new DataTable();
                DataRow dr = null;
                if (txtNoofItems.Text == "")
                {
                    Repeater2.DataSource = dt;
                    Repeater2.DataBind();
                }
                else
                {
                    int a = Convert.ToInt32(txtNoofItems.Text);                
                    dt.Columns.Add(new DataColumn("ItemName", typeof(string)));
                    dt.Columns.Add(new DataColumn("Qnty", typeof(string)));
                    dt.Columns.Add(new DataColumn("Cost", typeof(string)));                
                    for (int i = 0; i < a; i++)
                    {
                        dr = dt.NewRow();
                        dr["ItemName"] = string.Empty;
                        dr["Qnty"] = string.Empty;
                        dr["Cost"] = string.Empty;
                        //dr["Value"] = 0;
                        dt.Rows.Add(dr);
                    }
                }
                if (Repeater2.Visible == false)
                {
                    Repeater2.Visible = true;
                }
                ViewState["CurrentTable"] = dt;
                Repeater2.DataSource = dt;
                Repeater2.DataBind();
            }
            private void SetupdateRow()
            {
                DataTable dt = new DataTable();
                DataRow dr = null;
                if (txtNoofItems.Text == "")
                {
                    Repeater3.DataSource = dt;
                    Repeater3.DataBind();
                }
                else
                {
                    int a = Convert.ToInt32(txtNoofItems.Text);
                    dt.Columns.Add(new DataColumn("ItemId", typeof(string)));
                    dt.Columns.Add(new DataColumn("variation", typeof(string)));
                    // dt.Columns.Add(new DataColumn("ddlItemId", typeof(string)));
                    dt.Columns.Add(new DataColumn("ItemName", typeof(string)));
                    dt.Columns.Add(new DataColumn("Qnty", typeof(string)));
                    dt.Columns.Add(new DataColumn("Cost", typeof(string)));
                    //dt.Columns.Add(new DataColumn("Value", typeof(Int32)));
                    for (int i = 0; i < a; i++)
                    {
                        dr = dt.NewRow();
                        //dr["ddlItemId"] = ;
                        dr["ItemId"] = string.Empty;
                        dr["variation"] = string.Empty;
                        dr["ItemName"] = string.Empty;
                        dr["Qnty"] = string.Empty;
                        dr["Cost"] = string.Empty;
                        //dr["Value"] = 0;
                        dt.Rows.Add(dr);
                    }
                }
    
                if (Repeater3.Visible == false)
                {
                    Repeater3.Visible = true;
                }
                ViewState["CurrentTable"] = dt;
                //Bind the Repeater with the DataTable
                if (Repeater2.Visible == true)
                {
                    Repeater2.Visible = false;
                }
                if (Repeater1.Visible == false)
                {
                    Repeater1.Visible = true;
                }
                Repeater3.DataSource = dt;
                Repeater3.DataBind();
            }
            //function for allotting no.s rows
            protected void LnkBtnNoofItems_Click1(object sender, EventArgs e)
            {
                if (txtStore.Text == "")
                {
                    lblMessage.CssClass = "alert alert-warning";
                    lblMessage.Text = "Msg 002: Please select a SiteId";
                }
                else
                {
                    if (txtNoofItems.Text == "")
                    {
                        lblMessage.CssClass = "alert alert-warning";
                        lblMessage.Text = "Msg 003: please enter a number";
                        //TextBox txtName = (TextBox)Item.FindControl("txtName");
                        Repeater2.Visible = false;
                        Repeater3.Visible = false;
                    }
                    else
                    {
                        SqlConnection conn = new SqlConnection(ConString);
                        string newTNumber = txtSplorder.Text;
                        int splord = Convert.ToInt32(newTNumber);
                        string SQLUpdtTNum = "";
                        string SQL_vfy = "";
    
                        SQL_vfy = "select SplOrd_Num from PJ_Special_Order_T where SplOrd_Num =" + splord + "";
                        if (conn.State == ConnectionState.Closed)
                        {
                            conn.Open();
                        }
                        SqlDataReader Rd;
                        SqlCommand Cmd = new SqlCommand(SQL_vfy, conn);
                        Rd = Cmd.ExecuteReader();
                        if (Rd.Read())
                        {
                            int a = Convert.ToInt32(txtNoofItems.Text);
                            for (int i = 0; i < a; i++)
                            {
                                SetupdateRow();
                                //count = 1;
                            }
                            lblMessage2.CssClass = "";
                            lblMessage2.Text = "";
                            lblMessage.CssClass = "";
                            lblMessage.Text = "";
                            txtTotalQuantity.Text = "";
                            txtTotalValue.Text = "";
                        }
                        else
                        {
                            int a = Convert.ToInt32(txtNoofItems.Text);
                            for (int i = 0; i < a; i++)
                            {
                                SetInitialRow();
                                //count = 2;
                            }
                            lblMessage2.CssClass = "";
                            lblMessage2.Text = "";
                            lblMessage.CssClass = "";
                            lblMessage.Text = "";
                            txtTotalQuantity.Text = "";
                            txtTotalValue.Text = "";
                        }
                    }
                }
            }
            protected void Button2_Click(object sender, EventArgs e)
            {
                SqlConnection conn = new SqlConnection(ConString);
                string newTNumber = txtSplorder.Text;
                int splord = Convert.ToInt32(newTNumber);
                string SQLUpdtTNum = "";
    
                string SQL_vfy = "";
                SQL_vfy = "select SplOrd_Num from PJ_Special_Order_T where SplOrd_Num=" + splord + "";
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                SqlDataReader Rd;
                SqlCommand Cmd = new SqlCommand(SQL_vfy, conn);
                Rd = Cmd.ExecuteReader();
                if (Rd.Read())
                {
                    Rd.Close();
                    if (txtSplorder.Text != "")
                    {
                        string SQL_LstInvyNum = "";
                        SQL_LstInvyNum = "select Cast(LastJobID+1 as varchar) LastJobID from PJ_LastJobID";
                        if (conn.State == ConnectionState.Closed)
                        {
                            conn.Open();
                        }
                        SqlDataReader ResCmd;
                        SqlCommand SelCmd = new SqlCommand(SQL_LstInvyNum, conn);
                        ResCmd = SelCmd.ExecuteReader();
                        string tmpInvy = "";
                        if (ResCmd.Read())
                        {
                            tmpInvy = Convert.ToString(ResCmd["LastJobID"]);
                            txtSplorder.Text = tmpInvy;                       
                        }
                        ResCmd.Close();
                        conn.Close();
                        newTNumber = txtSplorder.Text;
                        int numValTNum = Int32.Parse(newTNumber);
                        SQLUpdtTNum = "Update  PJ_LastJobID SET LastJobID = " + numValTNum + "";
                        SqlCommand cmd = new SqlCommand(SQLUpdtTNum, conn);
                        if (conn.State == ConnectionState.Closed)
                        {
                            conn.Open();
                        }
                        int temp = cmd.ExecuteNonQuery();
                        conn.Close();
                        string message = "Your details have been saved successfully with new Invy No. i.e   " + tmpInvy;
                        string script = "window.onload = function(){ alert('";
                        script += message;
                        script += "')};";
                        ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
                        ResCmd.Close();
                        conn.Close();
                    }
                    Rd.Close();
                }
                else
                {
                    SqlConnection conn1 = new SqlConnection(ConString);
                    newTNumber = txtSplorder.Text;
                    int numValTNum = Convert.ToInt32(newTNumber);
                    SQLUpdtTNum = "Update  PJ_LastJobID SET LastJobID = " + numValTNum + "";
                    SqlCommand crd = new SqlCommand(SQLUpdtTNum, conn1);
                    if (conn1.State == ConnectionState.Closed)
                    {
                        conn1.Open();
                    }
                    int temp = crd.ExecuteNonQuery();
                    conn1.Close();
                }
            }
            protected void Button3_Click(object sender, EventArgs e)
            {
            }
            protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)
            {
                if (e.CommandName == "UpdateDatabase")
                {
                    try
                    {
                        foreach (RepeaterItem item in Repeater2.Items)
                        {
                            string SQLIns = "";
                            string newSalesInvyNum = txtSplorder.Text;
                            int splorder = Convert.ToInt32(newSalesInvyNum);
                            string newInvyDate = txtDate.Text;
                            string note = txtnote.Text;    
                            string Site = txtStore.Text;
                            int storenum = Convert.ToInt32(Site);
                            string ItemId = ((TextBox)item.FindControl("ItemId")).Text;
                            string variation = ((TextBox)item.FindControl("variation")).Text;
                            string ItemName = ((TextBox)item.FindControl("ItemName")).Text;
                            string Qty = ((TextBox)item.FindControl("Qnty")).Text;
                            Int32 newNumQty = Convert.ToInt32(Qty);
                            string Cost = ((TextBox)item.FindControl("Cost")).Text;
                            Decimal newNumCost = Convert.ToDecimal(Cost);
    
                            Int32 Orgnl_Qty;
                            //--- Check for the same item already exists...
                            string SQL_verify = "";
                            //SQL_verify = "select ItemId,Qty from IC_Inventory_T where Invy_Num = '" + newSalesInvyNum + "' and ItemId = '" + newItemId + "'";
    
                            SqlDataReader ResData;
                            SqlConnection conn = new SqlConnection(ConString);
                            if (conn.State == ConnectionState.Closed)
                            {
                                conn.Open();
                            }
                            SQLIns = "Insert into PJ_Special_Order_T (SplOrd_Num,SplOrd_Date,SplOrd_Notes,Store_Number,ItemNumber,Variation,ItemName,Qty,Price) values   (" + splorder + ",'" + newInvyDate + "','" + note + "'," + storenum + ",'" + ItemId + "','" + variation + "','" + ItemName + "'," + newNumQty + "," + newNumCost + ")";
    
                            SqlCommand cmd = new SqlCommand(SQLIns, conn);
    
    
    
                            conn = new SqlConnection(ConString);
    
    
    
                            if (conn.State == ConnectionState.Closed)
    
                            {
    
                                conn.Open();
    
                            }
    
    
    
                            int temp = cmd.ExecuteNonQuery();
    
    
    
    
    
    
    
                            txtNoofItems.Text = "";
    
    
    
    
                            conn.Close();
    
    
    
    
                        }
    
    
    
                    }
    
    
    
    
    
                    catch (Exception ex)
    
                    {
    
                        lblMessage2.Visible = true;
    
                        lblMessage2.CssClass = "alert alert-warning";
    
                        lblMessage2.Text = "Msg 004: Please enter valid data";
    
    
    
                    }
    
    
    
    
    
    
    
    
    
                }
    
    
                Repeater2.Visible = false;
    
                Repeater3.Visible = false;
    
                Response.Redirect("PRJ_SpecialOrder.aspx");
    
            }
    
            protected void TxtInventoryNumber_TextChanged(object sender, EventArgs e)
    
            {
    
    
    
    
    
                string SQLGetTrn = "";
    
                string CurrTNumber = txtSplorder.Text;
    
                txtSplorder.Text = CurrTNumber;
                int splorder = Convert.ToInt32(CurrTNumber);
    
                SQLGetTrn = "select distinct PJ_Location_M.Location,PJ_Special_Order_T.SplOrd_Notes,PJ_Special_Order_T.SplOrd_Date,PJ_Special_Order_T.Store_Number from  PJ_Location_M,PJ_Special_Order_T where PJ_Location_M.Store_Number = PJ_Special_Order_T.Store_Number and  PJ_Special_Order_T.SplOrd_Num =" + splorder + "";
    
                SqlConnection conn = new SqlConnection(ConString);
    
                //SqlCommand cmd = new SqlCommand("IC_INVENTORY_TByInvy_NumSelectAll", conn);
    
                //cmd.CommandType = CommandType.StoredProcedure;
    
                //cmd.Parameters.AddWithValue("@temp", CurrTNumber);
    
                if (conn.State == ConnectionState.Closed)
    
                {
    
                    conn.Open();
    
                }
    
                SqlDataReader ResCmd;
    
                SqlCommand SelCmd = new SqlCommand(SQLGetTrn, conn);
    
    
    
                if (CurrTNumber != "")
    
                {
    
                    ResCmd = SelCmd.ExecuteReader();
    
    
    
                    if (ResCmd.Read())
    
                    {
    
    
    
                        string tmpDate = Convert.ToString(ResCmd["SplOrd_Date"]);
    
    
    
                        int foundS1 = tmpDate.IndexOf(" ");     //position of first blank
    
    
    
                        //position of first blank
    
                        DateTime dt = new DateTime();
    
                        dt = Convert.ToDateTime(tmpDate);
    
    
    
                        string newInvyDate = dt.ToString("MM-dd-yyyy");
    
                        txtDate.Text = newInvyDate;
    
                        txtLocation.Text = Convert.ToString(ResCmd["Location"]);
                        txtnote.Text = Convert.ToString(ResCmd["SplOrd_Notes"]);
                        txtStore.Text = Convert.ToString(ResCmd["Store_Number"]);
                        txtDate.ReadOnly = true;
    
                        txtLocation.ReadOnly = true;
    
                        lnkinvydate.Enabled = false;
    
                        imgbtnSite.Enabled = false;
    
                    }
    
                    else
    
                    {
    
                        txtDate.ReadOnly = false;
    
                        txtLocation.ReadOnly = false;
    
                        lnkinvydate.Enabled = true;
    
                        imgbtnSite.Enabled = true;
    
                    }
    
                }
    
                if (Repeater2.Visible == true)
    
                {
    
                    Repeater2.Visible = false;
    
                }
    
                if (Repeater3.Visible == true)
    
                {
    
                    Repeater3.Visible = false;
    
                }
    
                lblMessage.Text = "";
    
                lblMessage.CssClass = "";
    
                lblMessage2.Text = "";
    
                lblMessage2.CssClass = "";
    
                conn.Close();
    
                conn.Dispose();
    
                GetData();
    
                dt.Rows.Add("", "", "", "", "", "");
    
                Repeater1.Visible = true;
    
                Repeater1.DataSource = dt;
    
                Repeater1.DataBind();
    
            }
    
            protected void btnclear_Click(object sender, EventArgs e)
    
            {
                Response.Redirect("PRJ_SpecialOrder.aspx");
                //Repeater3.Visible = false;
    
                //Repeater1.Visible = false;
    
                //Repeater2.Visible = false;
    
                //txtLocation.Text = "";
    
                //txtTotalValue.Text = "";
    
                //txtTotalQuantity.Text = "";
    
                //txtDate.Text = "";
    
                //txtStore.Text = "";
    
                //txtNoofItems.Text = "";
    
                //lblMessage.Text = "";
    
                //lblMessage2.Text = "";
    
                //lblMessage2.CssClass = "";
    
                //lblMessage.CssClass = "";
    
            }
    
            protected void Qnty_TextChanged(object sender, EventArgs e)
    
            {
    
                Int32 sumqty = 0;
    
                decimal sum = 0;
    
                try
    
                {
    
                    foreach (RepeaterItem item in Repeater2.Items)
    
                    {
    
                        string Qty = ((TextBox)item.FindControl("Qnty")).Text;
                        int Qty1 = Convert.ToInt32(((TextBox)item.FindControl("Qnty")).Text);
                        if (Qty1 > 0)
                        {
                            if (Qty != "")
                            {
                                Int32 newNumQty = Convert.ToInt32(Qty);
                                string Cost = ((TextBox)item.FindControl("Cost")).Text;
                                Decimal newNumCost = Convert.ToDecimal(Cost);
                                Decimal totalcost = (newNumCost * newNumQty);
                                ((TextBox)item.FindControl("Value")).Text = totalcost.ToString();
                                totalcost = (newNumCost * newNumQty);
                                ((TextBox)item.FindControl("Value")).Text = totalcost.ToString();
                                sumqty = sumqty + newNumQty;
                                txtTotalQuantity.Text = sumqty.ToString();
    
                                sum = sum + totalcost;
                                txtTotalValue.Text = sum.ToString();
                                lblMessage.Text = "";
                                lblMessage2.Text = "";
                                lblMessage2.CssClass = "";
                                lblMessage.CssClass = "";
                            }
                        }
                        else
                        {
                            ((TextBox)item.FindControl("Qnty")).Text = "";
                            ((TextBox)item.FindControl("Value")).Text = "";
                            string message = "Quantity should be greater than 0 and valid";
                            string script = "window.onload = function(){ alert('";
                            script += message;
                            script += "')};";
                            ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
                            break;
                        }
    
                        //Session["event_control"] = ((TextBox)Repeater2.FindControl("ItemId"));
                    }
    
    
                }
    
                catch
    
                {
    
                    lblMessage.Visible = true;
    
                    lblMessage2.CssClass = "alert alert-warning";
    
                    lblMessage2.Text = "Msg 005: Please select an Item No.";
    
                }
    
    
    
    
    
            }
    
            protected void Repeater2_ItemCreated(object sender, RepeaterItemEventArgs e)
    
            {
    
    
    
            }
    
            protected void Repeater3_ItemCommand(object source, RepeaterCommandEventArgs e)
            {
                if (e.CommandName == "Update")
                {
                    try
                    {
                        foreach (RepeaterItem item in Repeater3.Items)
                        {
                            string SQLIns = "";
                            string newSalesInvyNum = txtSplorder.Text;
                            int splorder = Convert.ToInt32(newSalesInvyNum);
                            string newInvyDate = txtDate.Text;
    
                            string note = txtnote.Text;
    
    
    
                            string Site = txtStore.Text;
                            int storenum = Convert.ToInt32(Site);
    
    
                            string ItemId = ((TextBox)item.FindControl("ItemId")).Text;
    
                            string variation = ((TextBox)item.FindControl("variation")).Text;
    
    
    
                            string ItemName = ((TextBox)item.FindControl("ItemName")).Text;
    
    
    
                            string Qty = ((TextBox)item.FindControl("Qnty")).Text;
    
                            Int32 newNumQty = Convert.ToInt32(Qty);
    
    
    
                            string Cost = ((TextBox)item.FindControl("Cost")).Text;
    
                            Decimal newNumCost = Convert.ToDecimal(Cost);
    
    
    
                            Int32 Orgnl_Qty;
    
    
    
                            //--- Check for the same item already exists...
    
                            string SQL_verify = "";
    
                            //SQL_verify = "select ItemId,Qty from IC_Inventory_T where Invy_Num = '" + newSalesInvyNum + "' and ItemId = '" + newItemId + "'";
    
    
    
                            SqlDataReader ResData;
    
                            SqlConnection conn = new SqlConnection(ConString);
    
    
    
                            if (conn.State == ConnectionState.Closed)
    
                            {
    
                                conn.Open();
    
                            }
    
    
    
    
    
                            SQLIns = "Insert into PJ_Special_Order_T (SplOrd_Num,SplOrd_Date,SplOrd_Notes,Store_Number,ItemNumber,Variation,ItemName,Qty,Price) values   (" + splorder + ",'" + newInvyDate + "','" + note + "'," + storenum + ",'" + ItemId + "','" + variation + "','" + ItemName + "'," + newNumQty + "," + newNumCost + ")";
    
                            SqlCommand cmd = new SqlCommand(SQLIns, conn);
    
    
    
                            conn = new SqlConnection(ConString);
    
    
    
                            if (conn.State == ConnectionState.Closed)
    
                            {
    
                                conn.Open();
    
                            }
    
    
    
                            int temp = cmd.ExecuteNonQuery();
    
    
    
    
    
    
    
                            txtNoofItems.Text = "";
    
    
    
    
                            conn.Close();
    
                        }
                    }
    
                    catch (Exception ex)
    
                    {
    
                        lblMessage.Visible = true;
    
                        lblMessage2.CssClass = "alert alert-warning";
    
                        lblMessage2.Text = "Msg 004: Please enter valid data";
    
    
    
    
                    }
    
    
    
    
    
                }
    
    
                Repeater2.Visible = false;
    
                Response.Redirect("PRJ_SpecialOrder.aspx");
    
                //Repeater3.Visible = false;
    
            }
    
            protected void Repeater3_ItemCreated(object sender, RepeaterItemEventArgs e)
    
            {
    
    
    
            }
    
            protected void Qnty_TextChanged1(object sender, EventArgs e)
    
            {
    
                Int32 sumqty = 0;
    
                decimal sum = 0;
    
                try
    
                {
    
                    Int32 newNumQty = 0;
    
                    Decimal totalcost = 0;
    
                    foreach (RepeaterItem item in Repeater3.Items)
    
                    {
    
                        string Qty = ((TextBox)item.FindControl("Qnty")).Text;
                        int qtynum = Convert.ToInt32(Qty);
                        if (qtynum > 0)
                        {
                            if (Qty != "")
                            {
                                newNumQty = Convert.ToInt32(Qty);
                                string Cost = ((TextBox)item.FindControl("Cost")).Text;
                                Decimal newNumCost = Convert.ToDecimal(Cost);
                                totalcost = (newNumCost * newNumQty);
                                ((TextBox)item.FindControl("Value")).Text = totalcost.ToString();
                                sumqty = sumqty + newNumQty;
                                txtTotalQuantity.Text = sumqty.ToString();
    
                                sum = sum + totalcost;
                                txtTotalValue.Text = sum.ToString();
                                lblMessage.Text = "";
                                lblMessage2.Text = "";
                                lblMessage2.CssClass = "";
                                lblMessage.CssClass = "";
                            }
                        }
                        else
                        {
                            ((TextBox)item.FindControl("Qnty")).Text = "";
                            ((TextBox)item.FindControl("Value")).Text = "";
                            string message = "Quantity should be greater than 0 and valid";
                            string script = "window.onload = function(){ alert('";
                            script += message;
                            script += "')};";
                            ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
                            break;
                        }
    
    
    
                    }
    
    
    
                }
    
                catch
    
                {
    
                    lblMessage.Visible = true;
    
                    lblMessage2.CssClass = "alert alert-warning";
    
                    lblMessage2.Text = "Msg 005: Please select an Item Number";
    
                }
    
    
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
    
            {
    
    
    
            }
    
            protected void BtnTopClear_Click(object sender, EventArgs e)
    
            {
                Response.Redirect("PRJ_SpecialOrder.aspx");
    
                //Repeater3.Visible = false;
    
                //Repeater1.Visible = false;
    
                //Repeater2.Visible = false;
    
                //txtLocation.Text = "";
    
                //txtTotalValue.Text = "";
    
                //txtTotalQuantity.Text = "";
    
                //txtDate.Text = "";
    
                //txtStore.Text = "";
    
                //txtNoofItems.Text = "";
    
                //lblMessage.Visible = false;
    
                //lblMessage2.Text = "";
    
                //lblMessage2.CssClass = "";
    
            }
    
            protected void ItemId_TextChanged(object sender, EventArgs e)
    
            {
    
                foreach (RepeaterItem item in Repeater2.Items)
    
                {
    
    
    
                    string ItemId = ((TextBox)item.FindControl("ItemId")).Text;
                    string variation = ((TextBox)item.FindControl("variation")).Text;
    
                    if (ItemId != "" && variation != "")
    
                    {
    
                        string SQLGetTrn;
    
                        SQLGetTrn = "select ItemName,SellingPrice from PJ_Item_M where ItemNumber = '" + ItemId + "' and Variation = '" + variation + "' ";
    
                        SqlConnection con = new SqlConnection(ConString);
    
                        if (con.State == ConnectionState.Closed)
    
                        {
    
                            con.Open();
    
                        }
    
                        SqlDataReader ResCd;
    
                        SqlCommand SelCmd = new SqlCommand(SQLGetTrn, con);
    
                        ResCd = SelCmd.ExecuteReader();
    
    
    
                        if (ResCd.Read())
    
                        {
    
                            if (IsPostBack)
    
                            {
    
                                ((TextBox)item.FindControl("ItemName")).Text = Convert.ToString(ResCd["ItemName"]);
    
                                ((TextBox)item.FindControl("Cost")).Text = Convert.ToString(ResCd["SellingPrice"]);
    
    
                            }
    
                        }
                        else
                        {
                            string message = "ItemID   or   Variation does not exist ";
    
                            string script = "window.onload = function(){ alert('";
    
                            script += message;
    
                            script += "')};";
    
                            ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
                        }
    
    
    
    
                    }
    
                    lblMessage.Visible = false;
    
                    lblMessage2.Text = "";
    
                    lblMessage2.CssClass = "";
    
                }
    
            }
    
            protected void ItemId_TextChanged1(object sender, EventArgs e)
    
            {
    
                foreach (RepeaterItem item in Repeater3.Items)
    
                {
    
    
    
                    string ItemId = ((TextBox)item.FindControl("ItemId")).Text;
                    string variation = ((TextBox)item.FindControl("variation")).Text;
                    if (ItemId != "")
    
                    {
    
                        string SQLGetTrn;
    
                        SQLGetTrn = "select ItemName,SellingPrice from PJ_Item_M where ItemNumber = '" + ItemId + "' and Variation = '" + variation + "'";
    
                        SqlConnection con = new SqlConnection(ConString);
    
                        if (con.State == ConnectionState.Closed)
    
                        {
    
                            con.Open();
    
                        }
    
                        SqlDataReader ResCd;
    
                        SqlCommand SelCmd = new SqlCommand(SQLGetTrn, con);
    
                        ResCd = SelCmd.ExecuteReader();
    
    
    
                        if (ResCd.Read())
    
                        {
    
                            if (IsPostBack)
    
                            {
    
                                ((TextBox)item.FindControl("ItemName")).Text = Convert.ToString(ResCd["ItemName"]);
    
                                ((TextBox)item.FindControl("Cost")).Text = Convert.ToString(ResCd["SellingPrice"]);
    
                            }
    
                        }
                        else
                        {
                            string message = "ItemID   or   Variation does not exist ";
    
                            string script = "window.onload = function(){ alert('";
    
                            script += message;
    
                            script += "')};";
    
                            ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
                        }
    
    
    
    
                    }
    
                    lblMessage.Visible = false;
    
                    lblMessage2.Text = "";
    
                    lblMessage2.CssClass = "";
    
                }
    
            }
    
            protected void txtSearch_TextChanged(object sender, EventArgs e)
            {
                //string conString = ConfigurationManager.ConnectionStrings["MyCon"].ToString();
                SqlConnection sqlcon = new SqlConnection(ConString);
                SqlCommand sqlcmd;
                SqlDataAdapter da;
                DataTable dt = new DataTable();
                String query;
                if (txtSearch.Text == "")
                {
                    query = "select ItemNumber,Variation,ItemName,SellingPrice from PJ_Item_M";
                }
                else
                {
                    query = "select ItemNumber,Variation,ItemName,SellingPrice from PJ_Item_M where ItemNumber like'" + txtSearch.Text + "%'";
                }
                sqlcmd = new SqlCommand(query, sqlcon);
                sqlcon.Open();
                da = new SqlDataAdapter(sqlcmd);
                dt.Clear();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
                }
                else
                {
                    GridView1.DataBind();
                    //Label1.Text = "No Records Found";
                    // ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
                }
                sqlcon.Close();
            }
    
            protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
    
    
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
    
                    TextBox txt1 = (TextBox)e.Item.FindControl("ItemId");
                    int tab1 = Convert.ToInt32(Session["tabs"].ToString()) + 1;
                    txt1.TabIndex = (short)tab1;
                    TextBox txt2 = (TextBox)e.Item.FindControl("Variation");
                    int tab2 = Convert.ToInt32(Session["tabs"].ToString()) + 2;
                    txt2.TabIndex = (short)tab2;
                    TextBox txt3 = (TextBox)e.Item.FindControl("Qnty");
                    int tab3 = Convert.ToInt32(Session["tabs"].ToString()) + 3;
                    txt3.TabIndex = (short)tab3;
    
                    Session["tabs"] = Convert.ToInt32(Session["tabs"].ToString()) + 3;
    
                }
    
    
    
    
            }
    
            public Control GetPostBackControl()
            {
                Control control = null;
    
                string ctrlname = Request.Params.Get("__EVENTTARGET");
                if (ctrlname != null && ctrlname != string.Empty)
                {
                    control = FindControl(ctrlname);
                    control.Focus();
                }
                else
                {
                    foreach (string ctl in Request.Form)
                    {
                        Control c = FindControl(ctl);
                        if (c is Button)
                        {
                            control = c;
                            break;
                        }
                    }
                }
                return control;
            }
    
            private bool SetNextFocus(ControlCollection controls, int tabIndex)
            {
                foreach (Control control in controls)
                {
                    if (control.HasControls())
                    {
                        bool found = SetNextFocus(control.Controls, tabIndex);
                        if (found) { return true; }
                    }
    
                    WebControl webControl = control as WebControl;
                    if (webControl == null) { continue; }
                    if (webControl.TabIndex != tabIndex) { continue; }
    
                    webControl.Focus();
                    return true;
                }
    
                return false;
            }
    
            protected void Repeater3_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
    
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
    
                    TextBox txt1 = (TextBox)e.Item.FindControl("ItemId");
                    int tab1 = Convert.ToInt32(Session["tabs"].ToString()) + 1;
                    txt1.TabIndex = (short)tab1;
                    TextBox txt2 = (TextBox)e.Item.FindControl("variation");
                    int tab2 = Convert.ToInt32(Session["tabs"].ToString()) + 2;
                    txt2.TabIndex = (short)tab2;
                    TextBox txt3 = (TextBox)e.Item.FindControl("Qnty");
                    int tab3 = Convert.ToInt32(Session["tabs"].ToString()) + 3;
                    txt3.TabIndex = (short)tab3;
                    //TextBox txt3 = (TextBox)e.Item.FindControl("Value");
                    //int tab3 = Convert.ToInt32(Session["tabs"].ToString()) + 3;
                    //txt3.TabIndex = (short)tab3;
                    Session["tabs"] = Convert.ToInt32(Session["tabs"].ToString()) + 3;
    
    
                }
            }
    
            protected void TextBox1_TextChanged(object sender, EventArgs e)
            {
                SqlConnection sqlcon = new SqlConnection(ConString);
    
                SqlCommand sqlcmd;
    
                SqlDataAdapter da;
    
                DataTable dt = new DataTable();
    
                String query;
    
    
    
                if (txtsearch1.Text == "")
    
                {
    
                    query = "select ItemNumber,Variation,ItemName,SellingPrice from PJ_Item_M";
    
                }
    
                else
    
                {
    
                    query = "select ItemNumber,Variation,ItemName,SellingPrice from PJ_Item_M where ItemNumber like'" + txtsearch1.Text + "%'";
    
                }
    
                sqlcmd = new SqlCommand(query, sqlcon);
    
                sqlcon.Open();
    
                da = new SqlDataAdapter(sqlcmd);
    
                dt.Clear();
    
                da.Fill(dt);
    
                if (dt.Rows.Count > 0)
    
                {
    
                    GridView2.DataSource = dt;
    
                    GridView2.DataBind();
    
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
    
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal1();", true);
    
    
    
                }
    
                else
    
                {
    
                    GridView2.DataBind();
    
                    //Label1.Text = "No Records Found";
    
                    // ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
    
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal1();", true);
    
                }
    
                sqlcon.Close();
    
            }
    
            protected void txtStore_TextChanged(object sender, EventArgs e)
            {
    
                string SQLGetTrn = "";
    
                string CurrTNumber = txtStore.Text;
    
                txtStore.Text = CurrTNumber;
    
                SQLGetTrn = "  select distinct PJ_Location_M.Location from PJ_Location_M where PJ_Location_M.Store_Number= " + CurrTNumber + "";
    
                SqlConnection conn = new SqlConnection(ConString);
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                SqlDataReader ResCmd;
                SqlCommand SelCmd = new SqlCommand(SQLGetTrn, conn);
    
                if (CurrTNumber != "")
                {
                    ResCmd = SelCmd.ExecuteReader();
    
                    if (ResCmd.Read())
                    {
                        txtLocation.Text = Convert.ToString(ResCmd["Location"]);
                        txtLocation.ReadOnly = true; 
                    }
    
                    else
                    {
                        txtDate.ReadOnly = false;
                        txtLocation.ReadOnly = false;
                        lnkinvydate.Enabled = true;
                        imgbtnSite.Enabled = true;
                    }
                }
            }      
    
            protected void lnkbtnItemNumber_Click(object sender, EventArgs e)
            {
                //((TextBox)item.FindControl("ItemId")).Text = Gridview1.lnkbtnItemNumber.Text;
            }
    
            protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "Select")
                {
                    //((TextBox)item.FindControl("ItemId")).Text = lnkbtnItemNumber.Text;
                    //((TextBox)item.FindControl("ItemId")).Text = GridView1.FindControl("lnkbtnItemNumber").ToString();
                    //((TextBox)Repeater2.FindControl("ItemId")) = GridView1.FindControl("lnkbtnItemNumber").ToString();
    
                    string selecteditem = Convert.ToString(e.CommandArgument);
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "closeModal();", true);
                    //((TextBox)item.FindControl("ItemId")).Text = selecteditem;
                    ((TextBox)Repeater2.Items[0].FindControl("ItemId")).Text = selecteditem;
                    ((TextBox)Repeater2.Items[0].FindControl("ItemId")).Focus();
                }
            }
        }
    }

    Tuesday, July 11, 2017 9:55 AM
  • User1182587605 posted

    I think the method SetNextFocus is taking the selected value away. Can that be undone.

    Tuesday, July 11, 2017 12:35 PM
  • User-271186128 posted

    Hello Deepak,

    According to your code, SetNextFocus method is used to set focus to the button control. When using this method, the GridView selected text could be successfully passed to the repeater textbox, but none of textboxes get focus.

    I still suggest you set a break point in the GridView RowCommand event.

            protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
            {
    // set a break point here to check whether it will trigger the RowCommand event. if (e.CommandName == "Select") { //((TextBox)item.FindControl("ItemId")).Text = lnkbtnItemNumber.Text; //((TextBox)item.FindControl("ItemId")).Text = GridView1.FindControl("lnkbtnItemNumber").ToString(); //((TextBox)Repeater2.FindControl("ItemId")) = GridView1.FindControl("lnkbtnItemNumber").ToString();
    //set a break point here to check whether you could get the selected value. string selecteditem = Convert.ToString(e.CommandArgument); //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "closeModal();", true); //((TextBox)item.FindControl("ItemId")).Text = selecteditem; ((TextBox)Repeater2.Items[0].FindControl("ItemId")).Text = selecteditem; ((TextBox)Repeater2.Items[0].FindControl("ItemId")).Focus(); } }

    After that, try to step by step to debug your code, make sure the repeater not re-bind.

    Best regards,
    Dillion

    Thursday, July 13, 2017 8:06 AM
  • User1182587605 posted

    Hi Dillion,

    I have set break points at both the places and the selected value is coming into the selecteditem string. I have debugged the code using breakpoint before as well. And even now, I am unable to produce the result. Still the same issue. The method setnextfocus is used to set focus to the next textbox in the repeater. I might have issues with that. Still no progress from my end. Please help me if you can to solve this.

    Regards,

    Deepak

    Thursday, July 13, 2017 8:54 AM
  • User-271186128 posted

    Hi Deepak, 

    I might have issues with that. Still no progress from my end. Please help me if you can to solve this.

    If possible I suggest you could share your application via OneDrive or GitHub, so that we could test your code, it might be easier for us to help you solve the problem.

    Best regards,
    Dillion

    Tuesday, July 18, 2017 8:02 AM
  • User1182587605 posted

    Thanks for coming back Dillion,

    This is the link for onedrive. I am sending you my full page. Please help me in this.

    https://1drv.ms/f/s!AhwP5QJCkRcHjlvXhQHv0vdoIqG7

    Please look for Gridview_RowCommand for the code which need to work.

    Deepak

    Tuesday, July 18, 2017 11:25 AM
  • User-271186128 posted

    Hi Deepak,

    Since you didn't provide the SQL database, I modify the columns using my data table. 

    In the GridView_RowCommand event, please debug your code and make sure you could find the TextBox control from the Repeater control. 

    If you can't find the TextBox, in the SetInitialRow method, you could add a row to the DataTable, then bind it to the Repeater Control.

    Besides, since, you are using ViewState to store the DataTable, in the GridView_RowCommand event, after get the selected item from GridView, you could add new data row to the DataTable and re-bind the Repeater control.

    code as below:

            protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "Select")
                {
    string selecteditem = Convert.ToString(e.CommandArgument); //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "closeModal();", true); ////If you are using the following code, please make sure the repeater control contains items. //((TextBox)item.FindControl("ItemId")).Text = selecteditem; //((TextBox)Repeater2.Items[0].FindControl("ItemId")).Text = selecteditem; //((TextBox)Repeater2.Items[0].FindControl("ItemId")).Focus(); //get the datatable DataTable dt = (DataTable)ViewState["CurrentTable"]; //add new item to datatable dt.Rows.Add(selecteditem, "", "", "", "", ""); ViewState["CurrentTable"] = dt; //rebind the repeater control. Repeater2.DataSource = dt; Repeater2.DataBind(); //update the UpdatePanel. InvyUpdatePanel.Update(); //close the modal popup mask. ScriptManager.RegisterStartupScript(this, GetType(), "Close Modal Popup", "Closepopup();", true); } }

    Code in JavaScript:

             function Closepopup() {
                        $(".modal-backdrop").remove();
                        $("#itemslistmodal").modal('hide');
    
                    }

    Then, after that you could call the UpdatePanel.Update() method to update the repeater content. And call the close modal method to close the Modal Popup mask.

    Best regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 19, 2017 6:46 AM
  • User1182587605 posted

    Thanks Dillion,

    I have tried what you told me. In debug, The selected value is going to the textbox in repeater but Dont know why the value is not coming into the repeater control. Can you help me with this.

    Regards,

    Deepak 

    Monday, July 24, 2017 6:03 AM
  • User1182587605 posted

    Hi Dillion,

    Sorry to come back again, I have debugged my code and still am unable to solve the issue. In my debug, The following code in my page is negating me to execute my task. Please check the code and help me solve my issue.

    public Control GetPostBackControl()
            {
                Control control = null;
    
                string ctrlname = Request.Params.Get("__EVENTTARGET");
                if (ctrlname != null && ctrlname != string.Empty)
                {
                    control = FindControl(ctrlname);
                    control.Focus();
                }
                else
                {
                    foreach (string ctl in Request.Form)
                    {
                        Control c = FindControl(ctl);
                        if (c is Button)
                        {
                            control = c;
                            break;
                        }
                    }
                }
                return control;
            }
    
    private bool SetNextFocus(ControlCollection controls, int tabIndex)
            {
                foreach (Control control in controls)
                {
                    if (control.HasControls())
                    {
                        bool found = SetNextFocus(control.Controls, tabIndex);
                        if (found) { return true; }
                    }
    
                    WebControl webControl = control as WebControl;
                    if (webControl == null) { continue; }
                    if (webControl.TabIndex != tabIndex) { continue; }
    
                    webControl.Focus();
                    return true;
                }
    
                return false;
            }

     Thanks,

    Deepak

    Wednesday, August 2, 2017 5:26 AM
  • User-271186128 posted

    Hi Deepak,

    . In debug, The selected value is going to the textbox in repeater but Dont know why the value is not coming into the repeater control. Can you help me with this.
    <!--?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" /--><o:p></o:p>

    Do you mean you could get the selected value in the GridView RowCommand event, but it doesn't display in the web page?<o:p></o:p>

    I have debugged my code and still am unable to solve the issue. In my debug, The following code in my page is negating me to execute my task. Please check the code and help me solve my issue.

    Try to comment out the SetNextFocus method (in the Page_PreRender method) and check whether the repeater control works well or not.

    If the repeater control works well, it means the issue is not related to the SetNextFocus method.

    Besides, since you are using foreach statement, I suppose the Focus will focus on the last control.

    And, since this threads is too long. If you have any further question, I suggest you could create a new thread.

    Best regards,
    Dillion

    Thursday, August 3, 2017 11:10 AM