Update ---
figured it out.
Slap this into the DeleteCommand...
Dim ID As String = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)
("Your Data Key Name").ToString()
---End Update
well it is face slap wednesday and I am confused.
all i want to do is have 2 columns. cancel (link button) and select (link button)
I can trap the selected value (datakeyname) using the selectedindex.. but cannot for the life of me see how to get it when i use the cancel command. I can return 'cancelled' in the msglabel... however I cannot get the value of the row that I need to work with.
source
| <telerik:RadGrid ID="RadGrid1" width="200px" runat="server" GridLines="None"> |
| <MasterTableView DataKeyNames="Pos_id"> |
| <Columns> |
| <telerik:GridButtonColumn CommandName="Delete" ButtonType="LinkButton" Text="Cancel" UniqueName="CancelCol" /> |
| <telerik:GridButtonColumn CommandName="Select" DataTextField="ListName" UniqueName="column1" /> |
| </Columns> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px" /> |
| </ExpandCollapseColumn> |
| </MasterTableView> |
| <ClientSettings> |
| <Selecting AllowRowSelect="True" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
Code:
| Protected Sub RadGrid1_DeleteCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.DeleteCommand |
| Try |
| 'Run a SQLNonQry to update data |
| 'repopulate |
| msglabel.Text = RadGrid1.SelectedValue & " Cancelled " |
| populateGrid() |
| Catch ex As Exception |
| msglabel.Text = ex.Message |
| End Try |
| End Sub |
| Protected Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged |
| 'update related ascx form |
| Ctrls_frm_CreatePosting.posid = RadGrid1.SelectedValue |
| msglabel.Text = RadGrid1.SelectedValue & " Selected" |
| End Sub |
| sub PopulateGrid() |
| 'basic grid populate with sql ds |
| end sub |