﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - Sifting operation in InitializeDataSource can not work ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Sifting-operation-in-InitializeDataSource-can-not-work-/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Sifting operation in InitializeDataSource can not work ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Sifting-operation-in-InitializeDataSource-can-not-work-/</link><pubDate>Wed, 14 Sep 2011 23:14:43 GMT</pubDate><dc:creator>handy@intersoftpt.com</dc:creator><description>&lt;p&gt;Hello Robert,&lt;/p&gt;&lt;p&gt;Please create another thread for the next time. We were talking a different product now. However, Xu GuoChun has resolved his issue in &lt;a href="http://intersoftpt.com/Community/ISDataSource/Search-problem-with-paging-operation-when-using-ISDataSource/" target="_blank"&gt;here&lt;/a&gt;. At does not problem if you want to use your own filter, but it would be better, if you handled all of them in InitializeDataSource. In order to handle it manually, you would need to turn off &lt;b&gt;&lt;i&gt;AllowAutoQueryHandler&lt;/i&gt;&lt;/b&gt;. In this way, you can load or filter with request which is called LoadOnDemand.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Handy&lt;/p&gt;</description></item><item><title>Sifting operation in InitializeDataSource can not work ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Sifting-operation-in-InitializeDataSource-can-not-work-/</link><pubDate>Wed, 14 Sep 2011 12:10:09 GMT</pubDate><dc:creator>RobertPehrson</dc:creator><description>&lt;p&gt;I have the same problem.  When its DataSource is a DataView, a WebCombo takes all the rows from the underlying DataTable without applying the RowFilter property.  However, it does apply the Sort property. &lt;/p&gt;
&lt;p&gt;Handy, your sample isn't the same, as it performs a new database Select to get a new dataset. In my case, I want to avoid accessing the database again, and so I create a DataView on an existing DataTable.&lt;/p&gt;
&lt;p&gt;The attached example shows the problem.  The first combo correctly contains all three rows of the DataTable. The second combo "WebComboDV" has a DataView as its DataSource with a RowFilter that filters out all but one row.  However, the combo is populated with all three rows, ignoring the DataView's RowFilter property - but it does sort the rows according to the Sort property.&lt;/p&gt;
&lt;p&gt;The following is code behind for the Programmatic WebCombo sample.&lt;/p&gt;&lt;pre&gt;public partial class cs_WebCombo_Programmatic_worked_DataView : System.Web.UI.Page
{
    DataTable dt;
       
    protected void Page_Load(object sender, EventArgs e)
    {
        WebCombo combo = new WebCombo("WebCombo1");
        combo.Width = Unit.Pixel(200);
        combo.Height = Unit.Pixel(20);
        combo.UseDefaultStyle = true;
        combo.DataTextField = "ColA";
        combo.DataValueField = "Id";

        WebCombo comboDV = new WebCombo("WebComboDV");
        comboDV.Width = Unit.Pixel(200);
        comboDV.Height = Unit.Pixel(20);
        comboDV.UseDefaultStyle = true;
        comboDV.DataTextField = "ColA";
        comboDV.DataValueField = "Id";

        // Setup Events
        combo.InitializeDataSource &amp;#43;= new DataSourceEventHandler(combo_InitializeDataSource);
        comboDV.InitializeDataSource &amp;#43;= new DataSourceEventHandler(combo_InitializeDataSourceDV);

        //this.Controls.Add(combo);
        this.DivContainer.Controls.Add(combo);
        this.DivContainer.Controls.Add(comboDV);

        dt = new DataTable();
        dt.Columns.Add("Id");
        dt.Columns.Add("ColA");
        dt.Columns.Add("ColB");
        dt.Columns.Add("ColC");

        dt.Rows.Add(new object[] { 1, "cell1A", "cell1B", "cell1C" });
        dt.Rows.Add(new object[] { 2, "cell2A", "cell2B", "cell2C" });
        dt.Rows.Add(new object[] { 3, "cell3A", "cell3B", "cell3C" });
        dt.AcceptChanges();
    }

    protected void combo_InitializeDataSource(object sender, DataSourceEventArgs e)
    {
        e.DataSource = dt;
    }

    protected void combo_InitializeDataSourceDV(object sender, DataSourceEventArgs e)
    {
        DataView dv = new DataView(dt, "ColA='cell2A'", "ColB DESC", DataViewRowState.CurrentRows);
        e.DataSource = dv;
    }
}
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>Sifting operation in InitializeDataSource can not work ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Sifting-operation-in-InitializeDataSource-can-not-work-/</link><pubDate>Fri, 02 Sep 2011 00:46:58 GMT</pubDate><dc:creator>handy@intersoftpt.com</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;What did you mean by not working? It works well in here. I can also show video to show that the filter or select query is working. It does not matter as long as your query in reselecting the data is correct.&lt;br /&gt;At least please send me a simple runable sample that replicates your issue. We will help you by debugging and see what's the missing part.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Handy&lt;/p&gt;</description></item><item><title>Sifting operation in InitializeDataSource can not work ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Sifting-operation-in-InitializeDataSource-can-not-work-/</link><pubDate>Thu, 01 Sep 2011 23:28:07 GMT</pubDate><dc:creator>gavin</dc:creator><description>&lt;p&gt;&lt;span style="font-size: 11pt"&gt;Hello Handy , &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp; Thank you for your reply and help . I am so sorry that&amp;nbsp;the method you put forward &amp;nbsp;did not work . I find it seem that this code like&amp;nbsp;&lt;span style="color: #f79646"&gt;dv.RowFilter = strRowFilter;  &lt;span style="color: #000000"&gt;and that code like &lt;span style="color: #f79646"&gt;e.DataSource = dv;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #000000; font-size: 0pt"&gt;can not use together . If I use two code together , the operation to sift data from database can not be executed . &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&lt;span style="color: #f79646"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #f79646"&gt;&lt;span style="color: #000000"&gt;&lt;span style="font-size: 15px"&gt;  Can you give some samples about using &lt;span style="color: #f79646"&gt;RowFilter&lt;/span&gt; to sift the data from webgrid ? I am looking forward to your respond eagerly . Thanks a lot !&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;

&lt;p&gt; &lt;/p&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Sifting operation in InitializeDataSource can not work ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Sifting-operation-in-InitializeDataSource-can-not-work-/</link><pubDate>Mon, 29 Aug 2011 05:22:52 GMT</pubDate><dc:creator>handy@intersoftpt.com</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;Try to set PostInputControl property in FlyPostBackSettings property as true. Sometimes the input is not correctly assigned to WebGrid if this property is turned off.&lt;br /&gt;I also attached my simple sample about shifting data. It is not using textbox, but it's using button. I think this can cover your current issue.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Handy&lt;/p&gt;</description></item><item><title>Sifting operation in InitializeDataSource can not work ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Sifting-operation-in-InitializeDataSource-can-not-work-/</link><pubDate>Wed, 24 Aug 2011 21:29:07 GMT</pubDate><dc:creator>gavin</dc:creator><description>&lt;p&gt;&lt;span style="font-size: 11pt"&gt;Hello Yudi ,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thanks for your reply and help . I think I did not describe clearly before . In the foreground program , I have a TextBox named txtJobName . To execute my program , I input a value in the TextBox and click the search button . I hope it will&amp;nbsp;sift&amp;nbsp;the data from database according to the jobname I input . &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; To debug my code , I find sifting the data from database is executed in InitializeDataSource , and the sifted data is correct . But the result is that the data of webgrid is not sifted . I do not know why was that . Besides , I add the two methods you recommended , but it does not work .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Can you give some samples about using RowFilter to sift the data from webgrid ?Because I do not know whether this problem&amp;nbsp;will occur when I use RowFilter to sift the data .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp;&amp;nbsp; Thanks a lot ! &amp;nbsp; 
&lt;div style="float: left; padding-top: 6px"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="pos"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="float: left; margin-left: 0px; padding-top: 6px"&gt;&lt;div style="width: 2px; float: left"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/p&gt;
</description></item><item><title>Sifting operation in InitializeDataSource can not work ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Sifting-operation-in-InitializeDataSource-can-not-work-/</link><pubDate>Wed, 24 Aug 2011 05:19:28 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Could you please let me know what exactly the search button does when it is clicked?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;On a simple case, when a button is clicked, the InitializeDataSource server-side event of WebGrid is invoked before the button click event. You might need to add ClearCachedDataSource() and RebindDataSource() method of WebGrid.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;protected void btnSearch_Click(object sender, EventArgs e)
{
    RefreshGrid(WG1, true);
    WG1.ClearCachedDataSource();
    WG1.RebindDataSource();
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Sifting operation in InitializeDataSource can not work ?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Sifting-operation-in-InitializeDataSource-can-not-work-/</link><pubDate>Tue, 23 Aug 2011 21:18:17 GMT</pubDate><dc:creator>gavin</dc:creator><description>&lt;p&gt;&lt;span style="font-size: 11pt"&gt;Hi , &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp;&amp;nbsp; In my&amp;nbsp;project code&amp;nbsp;, I find the sifting operation can not work .&lt;/span&gt;&lt;/p&gt;&lt;pre&gt; protected void WG1_InitializeDataSource(object sender,    ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
            DataView dv = Job.Select_AllJob();
            string strRowFilter = " 1=1 ";
            if (txtJobName.Text != "")
                strRowFilter &amp;#43;= "  and JobName like '%" &amp;#43; txtJobName.Text &amp;#43; "%'";
            dv.RowFilter = strRowFilter;&lt;br /&gt;            e.DataSource = dv;
}&lt;/pre&gt;&lt;pre&gt; protected void btnSearch_Click(object sender, EventArgs e)
{
            RefreshGrid(WG1, true);
}&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-size: 11pt"&gt;&amp;nbsp;&amp;nbsp; When I click the search button to sift the data from database according to the jobname , I find the result is the same as before . Then I debug my code , I find " dv.RowFilter " have the sifted data&amp;nbsp;, but after executing the code of " e.DataSource = dv; " , the rusult is the same as before . It mean the data from&amp;nbsp;database&amp;nbsp;is not be sifted .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;span style="font-size: 11pt"&gt;Anyone can help me ? Thank you very much !&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>