OnItemInserting Change values

2 posts, 0 answers
  1. Maurice Thompson
    Maurice Thompson avatar
    4 posts
    Member since:
    Apr 2003

    Posted 13 Mar 2012 Link to this post

    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,
  2. Tsvetina
    Admin
    Tsvetina avatar
    1874 posts

    Posted 16 Mar 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top