Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
Issue in Partial Databinding?
posted

Hi,

      I have an aspx page that has a Webgrid and also an ascx control. In the ascx page, user will be able to change the value and when they click "submit", i am updating the Grid control. I am doing so by using an delegate. There are problems that i face

1) When i load the default values in the Grid, it work fine, but when i click on the "Submit" button in the ascx page, the Grid is not updating to the new result, even though i bind the Grid with the new Dataset. Wht could be the problem?

2) For example, i have set the default value to 30 records, and i am scrolling down and viewing records that is more that 30. Now when i click on the "Submit" button and it fetches new records, i want 2 things to happen, First, i want the scroll position to be in the first record and Second i want to show only 30 records. ie., If i already viewed 90 records and the new Dataset has 340 records, wht it does is that in the grid, it shows the 90 records, and it will fetch only when i scroll down. I donot want that to happen, instead it should show only 30 records.

Please find the code below..

ASPX Page CS FILE

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using Infragistics.WebUI;

namespace PLXG
{
    public partial class WMS_Advance_Search : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected override void OnInit(EventArgs e)
        {
            this.UltraWebGrid1.Browser = BrowserLevel.Xml;
            this.UltraWebGrid1.DisplayLayout.LoadOnDemand = LoadOnDemand.Xml;
            this.UltraWebGrid1.DisplayLayout.XmlLoadOnDemandType = XmlLoadOnDemandType.Virtual;
            this.UltraWebGrid1.DisplayLayout.RowsRange = 30;
            this.UltraWebGrid1.InitializeDataSource += new InitializeDataSourceEventHandler(UltraWebGrid1_InitializeDataSource);
            base.OnInit(e);
        }

        void UltraWebGrid1_InitializeDataSource(object sender, UltraGridEventArgs e)
        {
            BindGrid();
        }

        private void BindGrid()
        {
            // Connect to SQL Northwind database
            SqlConnection con = new SqlConnection(@"data source=localhost;User ID=raja;password=raja;");
            // Get data between current row and row range provided by event args
            SqlCommand comm = new SqlCommand(@" select * from wms_activityhistory " , con);
            SqlDataAdapter da = new SqlDataAdapter(comm);
            DataTable dt = new DataTable();
            da.Fill(dt);
            // Set requested data for grid
            this.UltraWebGrid1.DataSource = dt;
        }

        private void GetPartialData(string searchword, int companyid)
        {
            // Connect to SQL Northwind database
            SqlConnection con = new SqlConnection(@"data source=localhost;User ID=raja;password=raja;");
            // Get data between current row and row range provided by event args
            SqlCommand comm = new SqlCommand(@" select * from wms_activityhistory WHERE companyid = " + companyid + "text like '%" + searchword + "%'", con);
            SqlDataAdapter da = new SqlDataAdapter(comm);
            DataTable dt = new DataTable();
            da.Fill(dt);
            // Set requested data for grid
            this.UltraWebGrid1.DataSource = dt;
        }

        public void onSearchBtnClick(SearchWord, CompanyId)
        {
            GetPartialData(SearchWord,CompanyId);
        }
    }
}

 

ASCX page

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WMS_Advance_Search.ascx.cs" Inherits="PLXG.WMS_Advance_Search" %>
<%@ Register Assembly="Infragistics2.WebUI.WebDataInput.v6.3, Version=6.3.20063.53, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
    Namespace="Infragistics.WebUI.WebDataInput" TagPrefix="igtxt" %>
<%@ Register Assembly="Infragistics2.WebUI.Misc.v6.3, Version=6.3.20063.53, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
    Namespace="Infragistics.WebUI.Misc" TagPrefix="igmisc" %>
<%@ Register Src="WMS_ProgressWindow.ascx" TagName="WMS_ProgressWindow" TagPrefix="uc2" %>

<script language="javascript" src="scripts/WebAsyn.js" type="text/javascript"></script>


<script id="Infragistics" type="text/javascript">
<!--

    function btnClose_Filter_Click(oButton, oEvent)
    {
        CloseFilter();
        oEvent.cancel=true;
        oEvent.cancelPostBack=true;
    }
   
  
   
    function CloseFilter()
    {
         CloseSearch();
    }
   
    function splDV_ctl01_ctl01_pnlSearch_InitializePanel(oPanel)
    {
         WebAsyn_InitializePanel(oPanel);
    }
    function pnlSearch_RefreshComplete(oPanel)
    {
       myDialog.Close();
       eventsAfterRefreshComplete();      
    }
   
    function eventsAfterRefreshComplete()
    {
        ChangeWpnl('splDV_ctl00_ctl01_WMS_Advance_Search1_wpnlcompany');
      
       var obj=document.getElementById('<%=hdnAdvancedOption.ClientID%>');
        if(obj.value == "1")
        {
            ShowAdvancedOption();
        }
        else
        {
            HideAdvancedOption();        
        }   
    }
   
    function ChangeWpnlImage(oWebPanelClientId)
    {
        var WebPanelHeaderImage = oWebPanelClientId + "_chk"
        document.getElementById(WebPanelHeaderImage).checked = true;
        InitializeWepPanel(oWebPanelClientId);
    }
   
    function ChangeWpnl(oWebPanelClientId)
    {
        var objPanel =igpnl_getPanelById(oWebPanelClientId);
        if(objPanel.getExpanded())
        {
             var WebPanelHeaderImage = oWebPanelClientId + "_chk"
             document.getElementById(WebPanelHeaderImage).checked = true;
            
             if(oWebPanelClientId == 'splDV_ctl00_ctl01_WMS_Advance_Search1_wpnlcompany')
             {
                 var Company1 = document.getElementById("<%=ddlCompany.ClientID%>");
                 var idxCompany1 = Company1.selectedIndex;
                 var valCompany1=Company1.options[idxCompany1].value;
                 if(valCompany1==0)//all
                 {       
                    document.all['ImgBtn_Company'].style.visibility='hidden';     
           
                 }
                 else
                 {
                    document.all['ImgBtn_Company'].style.visibility='Visible';   
                 }
             }
        }
       
    }
   
    function InitializeWepPanel(oWebPanelClientId)
    {
            if(oWebPanelClientId == 'splDV_ctl00_ctl01_WMS_Advance_Search1_wpnlcompany')
            {
                document.getElementById("<%=ddlCompany.ClientID%>").selectedIndex = 0;
                //document.all['ImgBtn_Company'].style.visibility='hidden';     
                document.getElementById("<%=txtCompany.ClientID%>").value = "ALL";
                document.getElementById("<%=txtCompanyID.ClientID%>").value = "0";
                //document.getElementById("<%=txtCompany.ClientID%>").readOnly=true;
            }
           
    }
    var expandWebPanel = "";
    function ExpandCollapsePanel(webPanelID)
    {
        expandWebPanel = "expand";
        var objPanel =igpnl_getPanelById(webPanelID);
        objPanel.setExpanded(!objPanel.getExpanded());
        if(webPanelID == "splDV_ctl00_ctl01_WMS_Advance_Search1_wpnlcompany")
        {
            var CmpPanel =igpnl_getPanelById('splDV_ctl00_ctl01_WMS_Advance_Search1_wpnlcompany');
            if(CmpPanel.getExpanded())
            {
                document.getElementById("<%=ddlCompany.ClientID%>").selectedIndex = 0;
                document.all['ImgBtn_Company'].style.visibility='hidden';     
                document.getElementById("<%=txtCompany.ClientID%>").value = "ALL";
                document.getElementById("<%=txtCompanyID.ClientID%>").value = "0";                
            }
            if(!CmpPanel.getExpanded())
            {
                document.getElementById("<%=txtCompanyID.ClientID%>").value = "ALL"
            }           
            //document.getElementById("<%=txtCompany.ClientID%>").readOnly=true;
        }
    }

    function fnddlCompany()
    {
        var Company = document.getElementById("<%=ddlCompany.ClientID%>"); 
        var idxCompany = Company.selectedIndex;
        var valCompany=Company.options[idxCompany].value;
       // document.getElementById("<%=txtCompany.ClientID%>").readOnly=false;
        if(valCompany==0)//all
        {       
            document.all['ImgBtn_Company'].style.visibility='hidden';     
            document.getElementById("<%=txtCompany.ClientID%>").value = "ALL";         
            document.getElementById("<%=txtCompanyID.ClientID%>").value = "ALL";
        }
        else if(valCompany==1)
        {
            if(document.getElementById("<%=txtCompany.ClientID%>").value == "ALL")
            {   
               document.getElementById("<%=txtCompany.ClientID%>").value = "";
            }
            document.all['ImgBtn_Company'].style.visibility='Visible';
        }   
        //document.getElementById("<%=txtCompany.ClientID%>").readOnly=true;
    }
   
   
    function newWin(url)
    {
      var Return = ShowDialog(url);
      if(Return != null)
        {
            if(Return.Name == "'ALL'")
            {
                Return.Name = Return.Name.replace("'","");                                   
            }
            if(Return.sessionid == "Company")
            {
               // document.getElementById("<%=txtCompany.ClientID%>").readOnly=false;
                document.getElementById("<%=txtCompany.ClientID%>").value = Return.Name;
                document.getElementById("<%=txtCompanyID.ClientID%>").value = Return.ID;   
                //document.getElementById("<%=txtCompany.ClientID%>").readOnly=true;                   
            }
        }
    }
   
    function HideAdvancedOption()
    {
         trAdvancedOption.style.display = 'none';
         document.getElementById("<%=tdImgCollapse.ClientID%>").style.display='none';
         document.getElementById("<%=tdImgExpand.ClientID%>").style.display='block';        
         var obj=document.getElementById('<%=hdnAdvancedOption.ClientID%>');
         obj.value = "0";
    }
   
    function ShowAdvancedOption()
    {
        trAdvancedOption.style.display = 'block';
        document.getElementById("<%=tdImgCollapse.ClientID%>").style.display='block';
        document.getElementById("<%=tdImgExpand.ClientID%>").style.display='none';        
        var obj=document.getElementById('<%=hdnAdvancedOption.ClientID%>');
        obj.value = "1";
    }
   
   

function wbtn_Search_Click(oButton, oEvent)
{
    if(document.getElementById("<%=txtSearchWord.ClientID%>").value.replace(/^\s+|\s+$/g, '') == "")
    {
        alert("Please enter the search word");
        document.getElementById("<%=txtSearchWord.ClientID%>").focus();
        oEvent.cancel=true;
        oEvent.cancelPostBack=true;
        return;
    }
   
    if(document.getElementById("<%=txtSearchWord.ClientID%>").value.length < 4)
        {
            alert("Please enter minimum 4 char(s)");
             oEvent.cancel=true;
             oEvent.cancelPostBack=true;
             return;
        }
       
    if((document.getElementById("<%=ddlCompany.ClientID%>").selectedIndex == 1) && (document.getElementById("<%=txtCompany.ClientID%>").value.replace(/^\s+|\s+$/g, '') == ""))
    {
        alert("Please select the company");
        oEvent.cancel=true;
        oEvent.cancelPostBack=true;
        return;
    }
}

function clickButton(e, buttonid)
{
  if (e.keyCode == 13)
  { 
  if(document.getElementById("<%=txtSearchWord.ClientID%>").value.replace(/^\s+|\s+$/g, '') == "")
   {
      alert("Please enter the search word");
      document.getElementById('<%=txtSearchWord.ClientID%>').focus();
      return false;
   }        
   else
    {            
     document.getElementById("<%=wbtn_Search.ClientID%>").click();
     document.getElementById('<%=txtSearchWord.ClientID%>').focus();
     return false;
    }     
  }
 
}


function WebTextEdit1_Focus(oEdit, text, oEvent)
{
     var editor = igedit_getById("splDV_ctl00_ctl01_WMS_Advance_Search1_wpnlwo_txtWOs");        
        if(editor.getText()== "ALL")       
            editor.setText("");
}
// -->
</script>
<table style="width:100%; height:100%" cellpadding="0" cellspacing="0">
<tr>
<td style="border-bottom:solid 1px black; height:22px;" class="commonCustomiseTopHeader">
<table width="100%" cellpadding="0" cellspacing="0">
       <tr valign="top" style="width:100%;height:22px;" class="Heading">
            <td  valign="middle">
                 <asp:Label id="Label1" SkinID="CCELabel" runat="server" Font-Bold="true"  Text="Search Options"
                   ></asp:Label>           
            </td>
           <td  align="right">
           <igtxt:WebImageButton ID="btnClose_Filter" Visible="true" SkinID = "CCEWebClose" runat="server" Text="" UseBrowserDefaults="False" ToolTip ="Close the Search Option window" AutoSubmit="false">
               <ClientSideEvents Click="CloseFilter();" />
            </igtxt:WebImageButton>
          
           </td>
       </tr>
</table>
</td>
</tr>
<tr valign="top">
<td>
    <table style="width: 100%" cellpadding="0" cellspacing="0" border="0">
        <tr style="height: 100%">
            <td style="height: 100%;padding-top:3px;" id="tdMain" runat="server" >
                <asp:Panel ID="Panel2" runat="server" SkinID="CCEPanel" Height="24px" Width="248px">
                    <table id="Table1" cellpadding="0" cellspacing="0" border="0" width="100%" style="padding-top: 5px;
                        padding-bottom: 5px">
                        <tr>
                            <td style="width: 94px">
                                <asp:Label ID="lblSearchWord" SkinID="CCELabel" runat="server" Width="89px" Text="Search by word"></asp:Label>
                            </td>
                            <td style="padding-left:10px;font-family:Verdana;font-size:9px; color: dimgray;padding-top:10px;">
                                <asp:TextBox ID="txtSearchWord" SkinID="CCETextBox" runat="server"  ></asp:TextBox>
                                (Minimum 4 chars)
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
                </td>
                </tr>
        <tr>
                <td>
                <table cellpadding="0" cellspacing="0" border="0" width="100%">               
                <tr>
                <td>           
                <igmisc:WebAsyncRefreshPanel ID="splDV_ctl01_ctl01_pnlSearch" runat="server"
                    Width="99%"  LinkedRefreshControlID="Pnl_GridSearch" RefreshComplete="pnlSearch_RefreshComplete"
                    InitializePanel="splDV_ctl01_ctl01_pnlSearch_InitializePanel">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                        <tr valign="top" style="width:100%;">
                            <td valign="top" style="padding-top:10px;">
                                <table width="100%" style="height:16px" cellpadding="0" cellspacing="0" border="0">
                                    <tr valign="top" style="width:100%;" class="Heading">
                                        <td valign="middle">
                                            <asp:Label ID="Label4" SkinID="CCELabel" runat="server" Font-Bold="true" Text="Advanced Search Options"></asp:Label>
                                        </td>
                                        <td  align="right">
                                        <table>
                                        <tr>
                                        <td runat="server" id="tdImgExpand">
                                             <img id="ImgExpand" title="click here to expand Advanced Search Option"
                                                style="cursor: hand;" onclick="ShowAdvancedOption()"
                                                src="App_Themes/CCEPLXGNewStyles/Images/srchExpand.gif" width="16" alt="" />
                                               
                                        </td>
                                        <td runat="server" id="tdImgCollapse">
                                                <img id="ImgCollapse" title="click here to collapse Advanced Search Option"
                                                style="cursor:hand;" onclick="HideAdvancedOption()"
                                                src="App_Themes/CCEPLXGNewStyles/Images/srchCollapse.gif" width="16" alt="" />
                                      
                                        </td>
                                        </tr>
                                        </table>
                                            </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr id = "trAdvancedOption">
                            <td style="height: 100%" id="td1" runat="server">
                                <asp:Panel ID="Panel1" runat="server" SkinID="CCEPanel" Height="100%">
                                    <igmisc:WebPanel ID="wpnlcompany" runat="server" ExpandEffect="None">
                                                        <ClientSideEvents ExpandedStateChanging="expanding"></ClientSideEvents>
                                                        <Header Text="&lt;INPUT id=&quot;splDV_ctl00_ctl01_WMS_Advance_Search1_wpnlcompany_chk&quot; onclick=&quot;ExpandCollapsePanel('splDV_ctl00_ctl01_WMS_Advance_Search1_wpnlcompany')&quot; type=checkbox value=&quot;ON&quot;/&gt;Company"
                                                            TextAlignment="Left">
                                                            <ExpandedAppearance>
                                                                <Style CssClass="ccefiltercommon">      
                                                                </Style>
                                                            </ExpandedAppearance>
                                                            <CollapsedAppearance>
                                                                <Style CssClass="ccefiltercommon">
                                                                 </Style>
                                                            </CollapsedAppearance>
                                                            <ExpansionIndicator Height="0px" Width="0px" />
                                                        </Header>
                                                        <Template>
                                                            <table cellpadding="0" cellspacing="0" border="0">
                                                                <tr id="tr1">
                                                                    <td style="padding-left: 20px">
                                                                        <asp:DropDownList ID="ddlCompany" SkinID="CCEDropdown" runat="server" Width="125px">
                                                                            <asp:ListItem Value="0" Selected="True">-------- All ---------</asp:ListItem>
                                                                            <asp:ListItem Value="1">In</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td height="1">
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td style="padding-left: 20px;" valign="top">
                                                                        <asp:TextBox ID="txtCompany" SkinID="CCETextBox" runat="server" Width="200px"></asp:TextBox>
                                                                    </td>
                                                                    <td id="TdImgBtn_Company" runat="server" style="width: 25px; padding-left: 4px;">
                                                                        <img id="ImgBtn_Company" title="click on this button to bring up the list of companies to filter"
                                                                            style="cursor: hand; visibility:hidden" onclick="BLOCKED SCRIPT var companyName = document.getElementById('<%=txtCompanyID.ClientID%>').value; newWin('WMS_SearchPopup.aspx?srch=Company&txtValue='+companyName)"
                                                                            src="App_Themes/CCEPLXGNewStyles/Images/getsearch.gif" width="25" alt="">
                                                                    </td>
                                                                    <td valign="top">
                                                                        <asp:TextBox ID="txtCompanyID" SkinID="CCETextBox" runat="server" Width="0px"></asp:TextBox>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </Template>
                                                        <PanelStyle Height="10px">
                                                        </PanelStyle>
                                                    </igmisc:WebPanel>
                                   
                                   
                                </asp:Panel>
                            </td>
                            </tr>
                            <tr>
                            <td height="40px" align="center" valign="middle">
                                <table cellpadding="0" cellspacing="0" class="ccebtntable">
                                    <tr>
                                        <td>
                                            <igtxt:WebImageButton ID="wbtn_Search" SkinID="CCEWebImgBtn" runat="server" ToolTip="Click here to Search" Text="Search"
                                                AutoSubmit="true" OnClick="wbtn_Search_Click" Focusable="true" ClickOnEnterKey="false" >
                                                <ClientSideEvents Click="wbtn_Search_Click" />
                                            </igtxt:WebImageButton>
                                        </td>
                                        <td>
                                            <igtxt:WebImageButton ID="wbtnCancel" SkinID="CCEWebImgBtn" runat="server" ToolTip="Click here to Close the Search window" Focusable="False"
                                                Text="Cancel" Width="92px" CausesValidation="False"  ClickOnEnterKey="false" AutoSubmit="false">
                                                <ClientSideEvents Click="CloseFilter();" />
                                            </igtxt:WebImageButton>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                 </igmisc:WebAsyncRefreshPanel>
                </td>
                </tr>
                </table>                
                 </td>
                </tr>
   </table>
                
  </td>
</tr>
</table>
<input type="hidden" runat="server" id="hdnTimePeriod" style="width: 0px" />
<input type="hidden" id="hdnAdvancedOption" runat="server" style="width: 0px" />

ASCX Cs File

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;

namespace PLXG
{
    public partial class WMS_Advance_Search : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void wbtn_Search_Click(object sender, Infragistics.WebUI.WebDataInput.ButtonEventArgs e)
        {
            searchWord_Filter();
        }

        private void searchWord_Filter()
        {
            try
            {
                string SearchWord = "";
                string CompanyId = "0";
                SearchWord = this.txtSearchWord.Text;

                //Company
                if (wpnlcompany.Expanded)
                {

                    if (this.txtCompany.Text == "All Companies" || this.txtCompany.Text == "ALL")
                    {
                        CompanyId = "0";
                    }
                    else
                    {
                        CompanyId = txtCompanyID.Text.ToString();
                    }
                }
                else // If the Company Filter is empty then save as 0.
                {
                    CompanyId = "0";
                }

                OnSearchBtnClick(SearchWord, CompanyId);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }

        #region SearchBtnClick delegates and events
        public delegate void onSearchBtnClickHandler(string SearchWord, string CompanyId);
        public event onSearchBtnClickHandler onSearchBtnClick;

        protected virtual void OnSearchBtnClick(string SearchWord, string CompanyId)
        {
            if (onSearchBtnClick != null)
            {
                onSearchBtnClick(SearchWord, CompanyId);
            }
        }
        #endregion
    }
}

Please help me out? Is there a solution for the above problem?

Thanks

Raja

 

Parents
No Data
Reply Children
No Data