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,
Do you have any sample code which can demo how the webgrid data reload according the webcombo selection. And the grid is binding with a webservices.
Thanks,
Don.,
I created a simple sample of WebGrid which will change WebGrid’s data by selecting a table name from an ASP.NET DropDownList control. The grid is bound to a WebService.
Initially, WebGrid will shows Customers data. When selected index of DropDownList get changed, set the ItemTypeName and SelectMethod based on the selected value of DropDownList. And last, invokes the LoadTablesStructureFromXml(string fileName) method to load the desired table structure and restore it to RootTable object of current WebGrid.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string tblName = DropDownList1.SelectedValue.ToString(); if (tblName != null && tblName != "") { WebGrid1.ClientBindingSettings.ItemTypeName = tblName; WebGrid1.ClientBindingSettings.ServiceMethods.SelectMethod = "Get" + tblName; WebGrid1.LoadTablesStructureFromXml(Server.MapPath(tblName + ".xml")); } }
For more detail, please check the aspx page and the aspx.cs file of the sample.
I enclosed the sample as attachment. Please have the attached sample evaluated on your end and let us hear whether it helps or not.
Thank you so much for your reply, but why i can't download the sample? is it the problem of my browser?
I have re-uploaded the sample in this post. Please feel free to let us know if you still have problems to download the sample.
Thanks you sample.
In you sample, the grid web method will be changed according to the combo value.
But is it possible that to use the same method and only pass the value of the combo value to that method and update the grid?
E.g. The grid is a infomation of Students and the combo is a list of Class. If i select a Class, the grid will show the studend that belong to that Class.
Thanks a lot.
...But is it possible that to use the same method and only pass the value of the combo value to that method and update the grid? E.g. The grid is a infomation of Students and the combo is a list of Class. If i select a Class, the grid will show the studend that belong to that Class. ...
Yes, it is possible to use the same method and pass a value to that method and update the grid.
In order to do this, please set the SelectMethod property of WebGrid to the desired WebMethod, for example: GetStudents.
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" BindingOperationMode="ClientBinding" ...> ... <ClientBindingSettings DataSourceType="WebService" ServiceUrl="../WebService.asmx" ItemTypeName="Students"> <ServiceMethods SelectMethod="GetStudents" /> </ClientBindingSettings> </ISWebGrid:WebGrid>
The GetStudents WebMethod should be defined like following snippet code so that we can pass select argument into it.
[WebMethod] public object GetStudents(DataSourceSelectArguments selectArguments) { if (selectArguments.Tag == "condition1") { // returns list of students based on condition1 } else if (selectArguments.Tag == "condition2") { // returns list of students based on condition2 } }
DataSourceSelectArguments class contains the following properties:
The Tag property is suitable for use in such scenario. Next, add following JavaScript function in the client-side to be used in ServiceEvents.
function Service_Selecting(control, selectArguments) { ... selectArguments.Tag = "condition1"; ... }
Note: Service_Selecting function is used in Selecting event. The Selecting event is invoked when the data provider is about to perform data selection.
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" BindingOperationMode="ClientBinding" ...> ... <ClientBindingSettings DataSourceType="WebService" ServiceUrl="../WebService.asmx" ItemTypeName="Students"> <ServiceMethods SelectMethod="GetStudents" /> <ServiceEvents Selecting="Service_Selecting" /> </ClientBindingSettings> </ISWebGrid:WebGrid>
Hope this helps.
Yudi,
Thank you so much for your help, the code is working prefectly fine.
Glad to hear the good news.
Should you need further assistance or run into any problems regarding our controls, feel free to post it into our forum. We would be happy to assist you again.
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