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
The page have a webgrid~~
but I have 3 Dataset,how to : bind these Dataset to webgrid dynamically (with the way "WebGrid1.DataBind()" ,not the way "e.DataSource = dataset1.DefaultView") I bind by DataBind() cause export excel wrong and can not use VirtualLoadMode.and so many questions with the way("DataBind() " )...
but how can i bind many datasouce dynamically ????
such as:
protected void Button9_Click(object sender, EventArgs e) { webgrid2.DataSource = myds();//second dataset webgrid2.DataBind(); webgrid2.RebindDataSource(); } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { webgrid2.DataSource = mytb();//first dataset webgrid2.DataBind(); webgrid2.RebindDataSource(); } }
With this way cause wrong "Unable to communicate with server.",It seems that webgrid can not use
" DataBind()"
Hello,
Please see my attached sample. I bind WebGrid with diffrent tables via button. Hope this helps.
Regards,Handy
You still have to use your data binding in InitializeDataSoruce event. Instead of using DataBind, e.DataSource should be working without a problem. I bind dynamically several tables with DropDownList option. It works well and I also can use VirtualLoad or export. Hope this helps.
hi Handy Surya,
I am sorry,your answer can not resolve my problem!I wanna bind many datasets dynamically without other control like"dropdownlist"!
Like MS's Gridview :
grid.DataSource = dataset1; grid.DataBind();
maybe webgrid does not support "multiTables-Binding",is not it???
only one bind way: e.DataSource ?but this way can not bind multiTables dynamically
how can i do???
Help me please!!
WebGrid supports your required scenario that binds WebGrid to multiple dataset.
I enclosed a sample where WebGrid initially bind to ‘Categories’ dataset of Northwind.mdb database. After the page load, you can change WebGrid’s datasource by selecting a table from the dropdownlist. You can still perform sorting, grouping, column moving and resizing after the new datasource has been applied.
Please check the attached sample for more detail information.
So, if you don't want to use DropDownList, may I know how do you want to bind your WebGrid dynamically? There should be someway you used to trigger bind dynamically in your scenario.
e.g in my sample, I used DropDownList. So, I need to know the detail before can suggest you a sample.
I am sure that our WebGrid supports multiTables.
Like this:
:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using H.Database; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using ISNet.WebUI.WebGrid; using ISNet.WebUI.WebCombo; namespace WebApplication1 { public partial class Demo : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindList(); } } protected void BindList() { using (StoreDA da = new StoreDA()) { var aa = da.Query(); this.WebGrid1.DataSource = da.Query1(TextBox1.Text); WebGrid1.RetrieveStructure(); WebGrid1.DataBind(); WebGrid1.RootTable.DataKeyField = "序列号"; WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true; } } protected void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e) { // BindList(); using (StoreDA da = new StoreDA()) { var aa = da.Query1("");//this is a query SQl,get a datatable e.DataSource = aa; WebGrid1.RetrieveStructure(); WebGrid1.RootTable.DataKeyField = "序列号"; WebGrid1.DataBind(); WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true; } } protected void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { using (StoreDA da = new StoreDA()) { var aa = da.Query1(TextBox1.Text); WebGrid1.DataSource = aa; WebGrid1.RetrieveStructure(); WebGrid1.RootTable.DataKeyField = "序列号"; WebGrid1.DataBind(); WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true; } } protected void Button2_Click(object sender, EventArgs e) { using (StoreDA da = new StoreDA()) { var aa = da.Query2(TextBox2.Text); WebGrid1.DataSource = aa; WebGrid1.RetrieveStructure(); WebGrid1.RootTable.DataKeyField = "序列号"; WebGrid1.DataBind(); WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true; } } protected void Button3_Click(object sender, EventArgs e) { using (StoreDA da = new StoreDA()) { var aa = da.Query3(TextBox3.Text); WebGrid1.DataSource = aa; WebGrid1.RetrieveStructure(); WebGrid1.RootTable.DataKeyField = "序列号"; WebGrid1.DataBind(); WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true; } } protected void Button4_Click(object sender, EventArgs e) { using (StoreDA da = new StoreDA()) { var aa = da.Query4(TextBox4.Text); WebGrid1.DataSource = aa; WebGrid1.RetrieveStructure(); WebGrid1.RootTable.DataKeyField = "序列号"; WebGrid1.DataBind(); WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true; } } when I input some informations and click a button,get a new dataset,I want bind the dataset to the same webgrid!How can I do ?Please help me!thank you!
thank you Handy Surya;
the answer is perfect!
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