hi all,
i just want to be sure that i'm working right with the grid..i manipulate data in the code behind, here is the ItemCommand sub
It's functioning well, but i want to be sure that my approach is correct, and there is no easier and better approach to do it.
To be more specific:
1. to get user inputs, i have to use FindControl function right?
2. to close the popup after success update i have to use
which don't work on insert so after success insert i use
3. on insert and update i need to use
but on delete i use
Wht do u think? am i getting it right?
thnx in advance
i just want to be sure that i'm working right with the grid..i manipulate data in the code behind, here is the ItemCommand sub
| Private Sub RadGrid2_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid2.ItemCommand |
| If e.CommandName = "Update" Then |
| If Page.IsValid Then |
| Dim item As GridEditableItem = CType(e.Item, GridEditableItem) |
| Dim objSection As New Sections(item.GetDataKeyValue("ID")) |
| objSection.SectionName = CType(item.FindControl("txtSectionName"), TextBox).Text |
| objSection.Update() |
| e.Item.Edit = False |
| End If |
| ElseIf e.CommandName = "PerformInsert" Then |
| If Page.IsValid Then |
| Dim item As GridEditableItem = CType(e.Item, GridEditableItem) |
| Dim objSection As New Sections() |
| objSection.SectionName = CType(item.FindControl("txtSectionName"), TextBox).Text |
| objSection.LangID = Session("Language") |
| objSection.SiteID = Session("Site") |
| objSection.Insert() |
| e.Canceled = True |
| e.Item.OwnerTableView.IsItemInserted = False |
| e.Item.OwnerTableView.Rebind() |
| End If |
| ElseIf e.CommandName = "Delete" Then |
| Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) |
| Dim objSection As New Sections(item.GetDataKeyValue("ID")) |
| objSection.Delete() |
| End If |
| End Sub |
It's functioning well, but i want to be sure that my approach is correct, and there is no easier and better approach to do it.
To be more specific:
1. to get user inputs, i have to use FindControl function right?
2. to close the popup after success update i have to use
| e.Item.Edit = False |
which don't work on insert so after success insert i use
| e.Canceled = True |
| e.Item.OwnerTableView.IsItemInserted = False |
| e.Item.OwnerTableView.Rebind() |
3. on insert and update i need to use
| Dim item As GridEditableItem = CType(e.Item, GridEditableItem) |
but on delete i use
| Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) |
Wht do u think? am i getting it right?
thnx in advance