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,
i am trying to load the webgrid onthe page load even by the following code OleDbCommand Cmd1 = Connection1.CreateCommand();
Cmd1.CommandType = CommandType.Text; Cmd1.CommandText = query; Cmd1.Connection.Open(); OleDbDataAdapter da1 = new OleDbDataAdapter(Cmd1); OleDbCommandBuilder comBuilder1 = new OleDbCommandBuilder(da1); DataTable dt1 = new DataTable(); da1.Fill(dt1); WebGrid1.DataSource = dt1; WebGrid1.DataBind(); Cmd1.Connection.Close();
But i am getting a webgrid with empty data. In the bottom of the grid it shows the loaded number exactly.
please help me to solve
thanks and regards
ca
Please pay attention to Glenn and my suggestion at the top. Please bind OnInitializeDataSource event and use OnPrepareDataBinding to retrieve structure. As i see at your code, you put all of them together and not in proper event. To customize WebGrid settings such as grouping, filter and virtual load, please set OnInitializeLayout event. I attached my working sample. Hope this helps.
Regards,Handy
In order to bind the data to WebGrid, please use InitializeDataSource server side event. Here is the snippet:
protected void grdObj_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e){ //GetDataTable function will return DataTable object e.DataSource = GetDataTable();}
InitializeDataSource is recommended because this event will conform to Intersoft component life cycle, especially for the flypostback mechanism.
Hello,
I suggest you to bind our WebGrid at OnInitializeDataSource event. As far I know, if the grid shows loaded number records on status bar but there is no data in WebGrid, it seems you forgot to RetrieveStructure. Below is the snippet code you need when you bind WebGrid programatically. Hope this helps.
protected void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e) { if (!IsPostBack) { WebGrid1.RetrieveStructure(); } }
can you please give me a complete code of example, in which i can populate the webgrid from database using backend C# programming.
string condition = Request.QueryString["cond"]; string connectString = ConfigurationManager.ConnectionStrings["ConnectionString2"].ConnectionString; OleDbConnection Connection1 = new OleDbConnection(connectString); OleDbCommand Cmd = Connection1.CreateCommand(); Cmd.CommandType = CommandType.Text; Cmd.CommandText = "SELECT MENU_PARAMETER_8 FROM ADM_MENU WHERE MENU_ID='" + condition + "'"; Cmd.Connection.Open(); OleDbDataAdapter da = new OleDbDataAdapter(Cmd); OleDbCommandBuilder comBuilder = new OleDbCommandBuilder(da); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { query = row[0].ToString(); } } Cmd.Connection.Close(); OleDbCommand Cmd1 = Connection1.CreateCommand(); Cmd1.CommandType = CommandType.Text; Cmd1.CommandText = query; Cmd1.Connection.Open(); OleDbDataAdapter da1 = new OleDbDataAdapter(Cmd1); OleDbCommandBuilder comBuilder1 = new OleDbCommandBuilder(da1); DataTable dt1 = new DataTable(); da1.Fill(dt1); WebGrid1.DataSource = dt1; WebGrid1.RetrieveStructure(); WebGrid1.DataBind(); Cmd1.Connection.Close();
this is the code i have used. Here i am getting the data displayed on the grid. But with this any of the functionality of grid sucha as grouping , virtual load, filtering etc are not working.
please reply me with example code and let me know how can enable features of your webgrid on that(like virtual load).
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