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 can't find a way to delete rows (or hide them) on server side , I attached my code.
The ' OnPreRender' event removes 2 rows , but it seems strange because the following line: grid.RootTable.GetRow(2); returns null on the client side 'Button2_onclick' event.
Your assistance will be highly appreciated.
Thanks,
Here is the source:
JAVASCRIPT:
function Button2_onclick()
{
var grid = ISGetObject("WebGrid1");
var table = grid.RootTable;
alert(grid.TotalRows);
var row4 = grid.RootTable.GetRow(0);
var row5 = grid.RootTable.GetRow(1);
var row6 = grid.RootTable.GetRow(2);
}
SERVER SIDE:
using System;
using System.Data;
using ISNet.WebUI.WebGrid;
using System.Web.UI.WebControls;
using System.Drawing;
using ISNet.WebUI;
using System.Collections.Generic;
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
WebGrid1.InitializeLayout += new LayoutEventHandler(ctlUltraGrid_InitializeLayout);
WebGrid1.InitializeDataSource += new DataSourceEventHandler(WebGrid1_InitializeDataSource);
WebGrid1.PrepareDataBinding += new DataSourceEventHandler(WebGrid1_PrepareDataBinding);
protected override void OnPreRender(EventArgs e)
WebGrid1.RootTable.Rows[3].Visible = false;
WebGrid1.RootTable.Rows[2].Visible = false;
// WebGrid1.RootTable.Rows.RemoveAt(2);
protected void ctlUltraGrid_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e)
if (!IsPostBack)
//Create the column
WebGridColumn wcol = new WebGridColumn("ItemName", "ItemName");
WebGrid1.RootTable.Columns.Add(wcol);
WebGridColumn wcol1 = new WebGridColumn("Discount", "Discount");
WebGrid1.RootTable.Columns.Add(wcol1);
WebGridColumn wcol2 = new WebGridColumn("Price", "Price");
WebGrid1.RootTable.Columns.Add(wcol2);
WebGrid1.RootTable.Layout.ColumnHeaders = ColumnVisibility.No;
e.Layout.ClientSideEvents.OnRowSelect = "DoRowSelect";
protected void WebGrid1_InitializeDataSource(object sender, DataSourceEventArgs e)
e.DataSource = GetTable();
else
e.DataSource = ViewState["oo"];
DataTable GetTable()
//
// Here we create a DataTable with four columns.
DataTable table = new DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Patient", typeof(string));
// Here we add five DataRows.
table.Rows.Add(25, "Indocin", "David");
table.Rows.Add(50, "Enebrel", "Sam");
table.Rows.Add(10, "Hydralazine", "Christoff");
table.Rows.Add(13, "Hydralazine1", "Christof1f");
table.Rows.Add(15, "Hydralazine2", "Christof2f");
table.Rows.Add(16, "Hydralazin3e", "Christof3f");
return table;
protected void WebGrid1_PrepareDataBinding(object sender, DataSourceEventArgs e)
WebGrid1.RetrieveStructure();
foreach (WebGridColumn item in WebGrid1.RootTable.Columns)
item.CellStyle.BackColor = System.Drawing.Color.Pink;
if (item.Position == WebGrid1.RootTable.Columns.Count - 1)
item.EditType = EditType.NoEdit;
var dt = WebGrid1.GetCachedDataSource();
ViewState["oo"] = dt;
Hello,Thank you for the question regarding WebGrid.Here’s the example snippet code how to hide a row in WebGrid from server side:
protected void Button1_Click(object sender, EventArgs e){ //Hide the 2nd row WebGrid1.RootTable.Rows[1].Visible = false; }
If you want to hide a row when WebGrid being loaded, you can use InitializeRow server side event.Here the example snippet code:
protected void WebGrid1_InitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e) { // Hide the 3rd row if (e.Row.KeyValue.ToString() == "3") e.Row.Visible = false; }
I attached the sample the use those code above. You could have review on the sample to see the result.I bind the WebGrid to access data source (Northwind.mdb database & Shippers table).You could download the sample from this link as well: http://1drv.ms/1kaksJqRegards,Hans K.
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