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

batch editing + advanced data binding + delete/insert/update

2 Answers 208 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Log
Top achievements
Rank 1
Log asked on 18 Sep 2013, 10:07 PM
Is there any example how do i update/delete/insert records when using radgrid in batch edit mode and it's using advanced data binding?
I couldnt find any.

If I have to do it manually how do i do it?
I could do it using
Protected Sub RadGrid1_BatchEditCommand(sender As Object, e As Telerik.Web.UI.GridBatchEditingEventArgs) Handles RadGrid1.BatchEditCommand
        For Each command As GridBatchEditingCommand In e.Commands
exec sql command.NewValues("fieldName")

But how do I detect if the command is update, insert or delete?



2 Answers, 1 is accepted

Sort by
0
Log
Top achievements
Rank 1
answered on 19 Sep 2013, 07:48 PM
I figured it out, it goez like this:
For Each command As GridBatchEditingCommand In e.Commands
If command.Type = GridBatchEditingCommandType.Delete Then
Dim anQId As Integer = CInt(command.OldValues("anQId"))
sqlStr = "DELETE FROM _RECWRK_Main WHERE anQId = @anQId"
sqlCommand.Parameters.Add("@anQId", SqlDbType.Int).Value = anQId
Try
                sqlCommand.ExecuteScalar()
            Catch ex As Exception
                NotifyUser("Updating database failed: " + ex.Message)
            End Try
but now ive got another problem. how do i bind dropdown itemtemplate in batch edited grid to dynamic (advanced) datasource, not datasourceid?

exactly same problem as this dude had:
http://www.telerik.com/community/forums/aspnet-ajax/grid/raddropdownlist-datasource-inside-radgrid.aspx

BUT!!
it doesnt work with me, RadGrid1_PreRender
RadGrid1.MasterTableView has no controls. why is that?
0
Log
Top achievements
Rank 1
answered on 19 Sep 2013, 11:56 PM
never mind, i figured this one out too:
u need to do  this:

code front:
<telerik:RadComboBox ID="acETDropDown" runat="server" OnPreRender="acETDropDown_PreRender" DataValueField="acET" DataTextField="acname">
</telerik:RadComboBox>    

code behind:

Protected Sub acETDropDown_PreRender(sender As Object, e As EventArgs)
        Dim combo As RadComboBox = TryCast(sender, RadComboBox)
        combo.DataSource = acETDropDownGetDataSource()
        combo.DataBind()
    End Sub

this example helped: http://www.telerik.com/community/forums/aspnet-ajax/grid/parent-child-comboboxs-in-new-q2-2013-batch-editing.aspx
Tags
Grid
Asked by
Log
Top achievements
Rank 1
Answers by
Log
Top achievements
Rank 1
Share this question
or