iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi ,
In my project code , I find the sifting operation can not work .
protected void WG1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e) { DataView dv = Job.Select_AllJob(); string strRowFilter = " 1=1 "; if (txtJobName.Text != "") strRowFilter += " and JobName like '%" + txtJobName.Text + "%'"; dv.RowFilter = strRowFilter; e.DataSource = dv; }
protected void btnSearch_Click(object sender, EventArgs e) { RefreshGrid(WG1, true); }
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 , but after executing the code of " e.DataSource = dv; " , the rusult is the same as before . It mean the data from database is not be sifted .
Anyone can help me ? Thank you very much !
Could you please let me know what exactly the search button does when it is clicked?
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.
protected void btnSearch_Click(object sender, EventArgs e) { RefreshGrid(WG1, true); WG1.ClearCachedDataSource(); WG1.RebindDataSource(); }
Hope this helps.
Hello Yudi ,
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 sift the data from database according to the jobname I input .
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 .
Can you give some samples about using RowFilter to sift the data from webgrid ?Because I do not know whether this problem will occur when I use RowFilter to sift the data .
Thanks a lot !
Hello,
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.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.
Regards,Handy
Hello Handy ,
Thank you for your reply and help . I am so sorry that the method you put forward did not work . I find it seem that this code like dv.RowFilter = strRowFilter; and that code like e.DataSource = dv; can not use together . If I use two code together , the operation to sift data from database can not be executed .
Can you give some samples about using RowFilter to sift the data from webgrid ? I am looking forward to your respond eagerly . Thanks a lot !
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.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.
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.
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.
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.
The following is code behind for the Programmatic WebCombo sample.
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 += new DataSourceEventHandler(combo_InitializeDataSource); comboDV.InitializeDataSource += 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; } }
Hello Robert,
Please create another thread for the next time. We were talking a different product now. However, Xu GuoChun has resolved his issue in here. 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 AllowAutoQueryHandler. In this way, you can load or filter with request which is called LoadOnDemand.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname