This is a migrated thread and some comments may be shown as answers.

[Solved] Update button click in VB

7 Answers 485 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 01 Mar 2013, 08:17 AM
If this is  code inserts into rad grid when in insert mode what would be the code that updates a grid when in edit mode?
Protected Sub btnAddRow_Click(sender As Object, e As EventArgs)
 
      If RadGrid4.MasterTableView.IsItemInserted Then
          RadGrid4.MasterTableView.PerformInsert()
      End If
      If RadGrid6.MasterTableView.IsItemInserted Then
          RadGrid6.MasterTableView.PerformInsert()
      End If
 
  End Sub

7 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 01 Mar 2013, 09:05 AM
Hello,

Protected Sub Button1_Click(sender As Object, e As EventArgs)
    For Each item As GridEditableItem In RadGrid1.EditItems
        item.FireCommandEvent("Update", item)
    Next
End Sub


Thanks,
Jayesh Goyani
0
Alex
Top achievements
Rank 1
answered on 01 Mar 2013, 09:25 AM
Thanks that works great!!!!! One more question? Ok In that same Grid I have a Boolean column that says billed how would I get that column to equal true when placed in edit mode? Thanks
0
Princy
Top achievements
Rank 2
answered on 01 Mar 2013, 09:50 AM
Hi,

I suppose you are using a CheckBoxColumn and want to show it as checked in edit mode. Here is the sample code.
VB:
Protected Sub RadGrid1_ItemDatBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
        Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
        Dim chk As CheckBox = DirectCast(item("CheckBoxColumn").Controls(0), CheckBox)
        chk.Checked = True
    End If
End Sub

Thanks,
Princy
0
Alex
Top achievements
Rank 1
answered on 01 Mar 2013, 05:36 PM
Ok So I could not get the check box to work. It could possible be my existing code. Ok so here is the process I click on one grid  and it put grid1 in edit mode is there any way at that point to have it also check my checkbox.
Protected Sub RadGrid2_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid2.ItemCommand
        If e.CommandName = "RowClick" Then
            Dim index As Integer = e.Item.ItemIndex
            Dim item As GridDataItem = DirectCast(RadGrid2.Items(index), GridDataItem)
            MCID = item("MCID").Text
            ViewState("CurrentMCID") = MCID
            Insurance = item("Insurance").Text
            ViewState("CurrentInsurance") = Insurance
 
            index = e.Item.ItemIndex
            item = DirectCast(RadGrid2.Items(index), GridDataItem)
            Units = item("Units").Text
            ViewState("CurrentUnits") = Units
 
            index = e.Item.ItemIndex
            item = DirectCast(RadGrid2.Items(index), GridDataItem)
            InsuranceGroup = item("InsuranceGroup").Text
            ViewState("CurrentInsuranceGroup") = InsuranceGroup
 
            index = e.Item.ItemIndex
            item = DirectCast(RadGrid2.Items(index), GridDataItem)
            Rate = item("Rate").Text
            ViewState("CurrentRate") = Rate
 
            index = e.Item.ItemIndex
            item = DirectCast(RadGrid2.Items(index), GridDataItem)
            Allowed = item("Allowed").Text
            ViewState("CurrentAllowed") = Allowed
 
            index = e.Item.ItemIndex
            item = DirectCast(RadGrid2.Items(index), GridDataItem)
            Tier = item("Tier").Text
            ViewState("CurrentTier") = Tier
 
            index = e.Item.ItemIndex
            item = DirectCast(RadGrid2.Items(index), GridDataItem)
            Minutes = item("Minutes").Text
            ViewState("CurrentMinutes") = Minutes
            RadGrid4.Rebind()
            RadGrid6.Rebind()
            For i As Integer = 0 To RadGrid1.PageSize - 1
                RadGrid1.EditIndexes.Add(i)
                RadGrid1.Rebind()
            Next
            
        End If
 
    End Sub
0
Shinu
Top achievements
Rank 2
answered on 02 Mar 2013, 06:53 AM
Hi,

I guess you are editing one RadGrid on Clicking the row of another RadGrid and you want to put the CheckBoxColumn of editing RadGrid to be Checked. As Princy has suggested, you can access the CheckBoxColumn of the Editing RadGrid in its ItemDataBound event and make it as  checked. please elaborate the scenario if it doesn't help.

Thanks,
Shinu.
0
Alex
Top achievements
Rank 1
answered on 02 Mar 2013, 07:05 AM
I tried his code I did not work. No error just did not check the box?
0
Kostadin
Telerik team
answered on 06 Mar 2013, 08:58 AM
Hello Alex,

Could you please elaborate a little bit more on your scenario? Sending us your code declaration and the related code behind will help us to pinpoint the reason for that behavior. This way we could provide you more to the point  answer.

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Alex
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Kostadin
Telerik team
Share this question
or