Display only date(datetime value) in Radwindow

4 posts, 0 answers
  1. vvvv
    vvvv avatar
    25 posts
    Member since:
    Aug 2011

    Posted 30 Jan 2014 Link to this post

    Hi, 
    I am using radwindow in a grid view. I display some details in the radwindow. I want to format the date field which is displayed in there and make it display only date part without the time part of it. Can that be done? Below is the code I use to get the date field into the radwindow label.

    PopUp.aspx.cs
    ============

    EventDateLabel.Text = EventInfoResultElement.eventDt.ToString();

    Thanks
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Jan 2014 in reply to vvvv Link to this post

    Hi,

    Please have a look into the sample code snippet which works fine at my end.

    C#:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            DateTime time = DateTime.Now;
            GridEditableItem item = (GridEditableItem)e.Item;
            RadWindow win = (RadWindow)item.FindControl("RadWindow1");
            Label EventDateLabel = (Label)win.ContentContainer.FindControl("Label1");
            EventDateLabel.Text = time.ToShortDateString();
        }
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. vvvv
    vvvv avatar
    25 posts
    Member since:
    Aug 2011

    Posted 31 Jan 2014 in reply to Shinu Link to this post

    Hi Shinu,

    Thanks for replying back.

    May be I should have been more clear. I have a hyperlink column in the radgrid. When I click on the hyperlink, radwindow shows up and I want to format the date displayed there by just displaying the date without time part of it. Could that be done?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Feb 2014 in reply to vvvv Link to this post

    Hi,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1">
        <MasterTableView>
            <Columns>
                <telerik:GridHyperLinkColumn HeaderText="" UniqueName="View" DataTextField="OrderID" DataTextFormatString="View" DataNavigateUrlFields="OrderID" DataNavigateUrlFormatString="javascript:OpenWindowPopup({0})">
                </telerik:GridHyperLinkColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    </telerik:RadWindowManager>

    JavaScript:
    <script type="text/javascript">
        function OpenWindowPopup(id) {
            var oWnd = radopen("Label.aspx", "RadWindowDetails");
        }  
    </script>

    Label.aspx:
    <asp:Label ID="EventDateLabel" runat="server">
    </asp:Label>

    C#(Label.aspx):
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime time = DateTime.Now;
        EventDateLabel.Text = time.ToShortDateString();
    }

    Thanks,
    Shinu.
Back to Top