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

Linq datasource parameters not working with Radgrid

1 Answer 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chamin
Top achievements
Rank 1
Chamin asked on 22 Oct 2012, 12:17 PM
Hi

I'm using rad grid and implemented parameters for insert,update and where.
But created parameters for update not updated the database. Insert and where parameters are working perfectly.

Please look at the code how I implemented in the project,

<asp:LinqDataSource ID="ldsDList" runat="server" <br>                        ContextTypeName="MDataContext" <br>                        EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntityTypeName="" <br>                        TableName="DLists"><br>                        <InsertParameters><br>                            <asp:ControlParameter ControlID="HFUser" Name="EnteredBy" <br>                            PropertyName="Value" Type="Int32" /><br>                            <asp:Parameter Name="DateEntered" Type="DateTime" /><br>                        </InsertParameters><br>                        <UpdateParameters><br>                            <asp:ControlParameter ControlID="HFUser" Name="ModifiedBy" <br>                            PropertyName="Value" Type="Int32" DbType="Int32" /><br>                            <asp:Parameter Name="DateModified" Type="DateTime" /><br>                        </UpdateParameters><br>                    </asp:LinqDataSource>



Protected Sub ldsDList_ContextCreating(sender As Object, e As System.Web.UI.WebControls.LinqDataSourceContextEventArgs) Handles ldsDList.ContextCreating<br>        If e.Operation = DataSourceOperation.Insert Then<br>            Me.ldsDList.InsertParameters("DateEntered").DefaultValue = DateTime.Now.ToString()<br>        ElseIf e.Operation = DataSourceOperation.Update Then<br>            Me.ldsDList.UpdateParameters("DateModified").DefaultValue = DateTime.Now.ToString()<br>        End If<br>    End Sub

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 25 Oct 2012, 10:28 AM
Hi Chamin,

You don't have to configure the UpdateParameters manually - it can cause errors easily. You should configure the updateParameters using wizards in Design-time:
  1. Select the LinqDataSource control on aspx.
  2. Click the "Update" property.
  3. Click "Add parameters" to add your updateParameters
A more clear demonstration on how to use LinqDataSource is shown in our demo. Also I suggest that you take a look at the following forum post.

Kind regards,
Angel Petrov
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
Chamin
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or