I am trying to convert a standard asp.net GridView to a RadGrid.
My set up is Windows XP Pro SP3, ASP.NET AJAX controls 2009 Q1 and Visual Studio 2008 3.5 Framework.
Is there a way to achieve the same thing with the RadGrid? I would appreciate it if anyone could point me in the right direction.
In the GridView I have code that will allow me to edit/update/cancel a record.
Please see below the asp.net code with standard GridView
| protected void Page_Load(object sender, EventArgs e) |
| { |
| //Load the categories grid only the first tim the page is loaded |
| if (!IsPostBack) |
| { |
| //Load the categories grid |
| BindGrid(); |
| } |
| } |
| //Populate the GrdView with data |
| private void BindGrid() |
| { |
| //Get category from query string |
| string categoryId = Request.QueryString["CategoryID"]; |
| //Get a DataTable object containing the categories |
| grid.DataSource = CatalogAccess.CatalogGetCategories(); |
| //Bind the data to the grid |
| grid.DataBind(); |
| } |
| //Enter row into edit mode |
| protected void grid_RowEditing(object sender, GridViewEditEventArgs e) |
| { |
| //set the row for which to enale edit mode |
| grid.EditIndex = e.NewEditIndex; |
| //set status message |
| statusLabel.Text = "Editing row " + e.NewEditIndex.ToString(); |
| //Reload the grid |
| BindGrid(); |
| } |
| protected void grid_RowUpdating(object sender, GridViewUpdateEventArgs e) |
| { |
| //retrieve the updated data |
| string id = grid.DataKeys[e.RowIndex].Value.ToString(); |
| string name = ((TextBox)grid.Rows[e.RowIndex].Cells[0].Controls[0]).Text; |
| string description = ((TextBox)grid.Rows[e.RowIndex].FindControl("descriptionTextBox")).Text; |
| //execute the update command |
| bool success = CatalogAccess.UpdateCategory(id, name, description); |
| //cancel edit mode |
| grid.EditIndex = -1; |
| //display status message |
| statusLabel.Text = success ? "Update successful" : "Update failed"; |
| //reload the grid |
| BindGrid(); |
| } |
Many thanks
Simon