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

radgrid sqldatasource set update parameter value in code behind

1 Answer 220 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lourdes
Top achievements
Rank 1
Lourdes asked on 12 Jun 2012, 06:39 PM
One of the variables in my update queries is the current date.  I don't know how to set it up ride on the sqldatasource.  Using the regular aspx gridview, I normally set this in the code behind.

I'm at a loss on how to do this in radgrid.  Here's the code that I've trying to solve.  Everything else works but when I do the update, it still cannot find this parameter.

I would appreciate the help.  Thank you!

 Protected Sub RadGrid1_UpdateCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
        SqlDataSource1.UpdateParameters.Add("@InactiveDate", SqlDbType.DateTime)
        SqlDataSource1.UpdateParameters("@InactiveDate").DefaultValue = Date.Now()


    End Sub

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 13 Jun 2012, 05:49 AM
Hello Lourdes,

One suggestion is you can set the parameter as shown below.
VB:
Protected Sub SqlDataSource1_Updating(sender As Object, e As SqlDataSourceCommandEventArgs)
    e.Command.Parameters("@UniqueName").Value = DateTime.Now
End Sub

Thanks,
Shinu.
Tags
Grid
Asked by
Lourdes
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or