RadDatePicker inside DataList

2 posts, 0 answers
  1. Mohammed Ahmed
    Mohammed Ahmed avatar
    13 posts
    Member since:
    Jul 2007

    Posted 02 Jan 2009 Link to this post

    I want to save the the selected date from the RadDataPicker within the datalist to the database here is the code I have

    from aspx side

     

    <asp:DataList ID="someid" runat="server" RepeatLayout="Table" ItemStyle-Width="300px"

     

     

    RepeatColumns="2" RepeatDirection="Vertical"

     

     

    DataKeyField="somekeydata" >

     

     

    <HeaderTemplate>

     

     

    <table>

     

     

    <tr>

     

     

    <td class="label" colspan="8">

     

    some info

     

    </td>

     

     

    </tr>

     

     

    </table>

     

     

    </HeaderTemplate>

     

     

    <ItemStyle />

     

     

     

    <ItemTemplate>

     

     

    <asp:Label ID="someid2" runat="server" Text=<%#Eval("somedata")%>></asp:Label>

     

     

    <asp:Label ID="someid3" runat="server" Text=<%#Eval("somedata")%> ></asp:Label>:

     

     

     

    <img id="someid4" runat="server" src="images/someimage.gif" alt="some alt." align="absmiddle"

     

     

    border="0" height="10" />

     

     

    <telerik:RadDatePicker ID="RadDate1" Runat="server" DbSelectedDate='<%#Bind("dates")%>' >

     

     

    </telerik:RadDatePicker>

     

     

    </ItemTemplate>

     

     

    </asp:DataList>

    Cs file

     

     

    private RadDatePicker getdate= new RadDatePicker();

     

     

     

    protected

     

    void Save_Click(object sender, EventArgs e)

     

    {

     

     

     

     

    foreach (DataListItem ls in someid.Items)

     

    {

     

    int key= (int)someid.DataKeys[ls.ItemIndex];

     

    getdate= (

    RadDatePicker)ls.FindControl("RadDate1");

     

     

    object somevariable = Convert.ToDateTime(getdate.SelectedDate); //each time the date is null

     

     

     

     

     

     

     

    }

     

     

    }

    I really appreciate for your help.

    Thanks

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 07 Jan 2009 Link to this post

    Hello Mohammed,

    One possible option in this case would be to use the client side api of the control, and trigger an AjaxRequest to the server. For example, when a selection is made, you can go to the server via an AjaxRequest, and persist the selected value in the database, or add it to the list.

    Best wishes,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top