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

OnItemInserting Change values

1 Answer 110 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Maurice Thompson
Top achievements
Rank 1
Maurice Thompson asked on 13 Mar 2012, 04:39 PM
Hi,

I am converting an existing ListView implementation  bound to an ObjectDataSource into a RadListView.
I have however reached a problem with the OnItemInserting event where I cannot see where to change the values that are being sent to the ObjectDataSource Insert Method
For example, in the existing ListView, I can specify:
protected void lvwTest_ItemInserting(object sender, ListViewInsertEventArgs e)
{
 e.Values["expert_id"] = 4;
}

 

How can I do this for a RadListView ?

Thanks,

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 16 Mar 2012, 10:01 AM
Hello Maurice,

As we already discussed the options in this scenario, I will summarize them and close this forum. If you have further concerns, please post in the formal support ticket.

One option, if InsertParameters are used it to assign them DefaultValue in the ItemCommand event:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="List"
     TypeName="Test.BL.Course" InsertMethod="CreateCourse">
     <InsertParameters>
         <asp:Parameter Name="CourseID" Type="Int64" />
         <asp:Parameter Name="CourseName" Type="String" />
     </InsertParameters>
 </asp:ObjectDataSource>
protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
{           
    if (e.CommandName == RadListView.PerformInsertCommandName)
    {              
        ObjectDataSource1.InsertParameters["CourseName"].DefaultValue = "Maths";
    }     
}

In other, more complex scenarios, it is possible to do the modifications in the insert method of the datasource control.

Also, we will consider giving control over the insert/edit values in RadListView in future versions of the controls.

Kind regards,
Tsvetina
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
ListView
Asked by
Maurice Thompson
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or