WebGrid provides a RowChecker feature which is very helpful to select multiple rows in WebGrid.
In this topic, you will learn the basic thing on how to get checked rows in server side.
To get checked rows in server side
- Add an ASP.NET button and TextBox in WebForm.
- On Button1_Click event handler, add this function:
C# Copy Code protected void Button1_Click(object sender, EventArgs e) { WebGrid1.ClientAction.InvokeScript("test"); TextBox1.Text = "Checked rows are : \n"; foreach (string keyValue in WebGrid1.RootTable.GetCheckedRows()) { TextBox1.Text += keyValue + " ; \n"; } }
- Run the project.
Tasks
Walkthrough: Adding RowChecker column in WebGrid
Walkthrough: Adding RowChecker in GroupRow
How-to: Persist row checker during PostBack
How-to: Get checked rows in client side
References
ButtonClick Event
ClientAction Property
GetCheckedRows Method
Other Resources
Walkthrough Topics
How-to Topics