Insert Item Template Help

2 posts, 0 answers
  1. Dave
    Dave avatar
    11 posts
    Member since:
    Jul 2011

    Posted 25 Jul 2011 Link to this post

    I am trying to insert data from a listview Insert Item Template into my datasource.  There are 2 fields that the user doesn't enter, but instead come from application variables.  How do I put these into the insert item template, or into the sql datasource insert?
  2. Thad
    Thad avatar
    106 posts
    Member since:
    Sep 2010

    Posted 02 Aug 2011 Link to this post

    Hi Dave,

    This should be what you need. It's easier to do it this way (in my opinion) than to try to modify the datasource.

    Add an event handler for ItemDataBound event.
    <telerik:RadListView ID="rlvTest" runat="server" OnItemDataBound="rlvTest_ItemDataBound">
            <asp:Label ID="lblId" runat="server" />

    In this event, check to see if the type of item being bound is an InsertItem, and if it is then find the control and set the value as you desire.
    protected void rlvTest_ItemDataBound(object sender, RadListViewItemEventArgs e)
        if (e.Item.ItemType == RadListViewItemType.InsertItem)
            Label label = e.Item.FindControl("lblId") as Label;
            if (label != null)
                label.Text = SomeApplicationVariable;

    Hope that helps!
Back to Top