Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 27th, 2007, 05:01 PM
Authorized User
 
Join Date: Feb 2007
Posts: 37
Thanks: 1
Thanked 0 Times in 0 Posts
Default Adding JSCalendar in Gridview Template Column ???

All,
              I want to display calendar when user clik on textbox inside gridview(which is TemplateField).I want to use pretty nice calendar control "JSCalendar" for that and not deafult provided by visual studio or AJAX CalendarExtendar pop up. I tired to use <input> field but it did not diplay properly and unable to bind it with DB field so i have to use <asp:textbox> templatefield for that. does any one have idea to embeded "jsCalendar" control inside GridView.

Thanks in advance.
Maulik

 
Old August 28th, 2007, 10:21 AM
Authorized User
 
Join Date: Feb 2007
Posts: 37
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I solved it by injecting some inline code.Here posting block of code responsible to display pretty nice "JsCalendar" and also bind it with database field.

<asp:TemplateField HeaderText="Expiration Date">
  <ItemTemplate>
    <!-- <asp:TextBox id="txtExpDate" Text = '<%# Eval
        ("expiration_date") %>' runat="server" Width="100px"
            Height="13px"></asp:TextBox> -->

  <input type="text" id='<%# GetExpirationFieldID() %>'
    name="txtExpDate" value= "<%# Eval("expiration_date") %>" readonly="readonly">

 <script type="text/javascript">
       Calendar.setup({
       inputField : '<%# GetExpirationFieldID() %>',// id
                                                of the input field
       ifFormat : "%B %d %Y",
       //daFormat : "%Y/%m/%d"
       showsTime : false,// will display a time selector
       button : '<%# GetExpirationFieldID() %>', //
                          trigger for the calendar (button ID)
       singleClick : false,// double-click mode
       step : 1 // show all years in drop-down
                          boxes (instead of every other year as
                                        default)
            });
  </script>

  <!-- <cc1:CalendarExtender ID="CalendarExtender1" runat="server"
             TargetControlID="txtExpDate"
             Format="MMMM d, yyyy" >
     </cc1:CalendarExtender> -->
  </ItemTemplate>
</asp:TemplateField>
-------------------------------------------------------------------
Besides above code we need to add reference for scripts and css related to jscalender.


<link rel="stylesheet" href="../Common/scripts/css/jscalendar/calendar-blue.css" type="text/css" />
    <script type="text/javascript" src="../Common/scripts/js/jscalendar/calendar_stripped.js"></script>
    <script type="text/javascript" src="../Common/scripts/js/jscalendar/lang/calendar-en.js"></script>
    <script type="text/javascript" src="../Common/scripts/js/jscalendar/calendar-setup_stripped.js"></script>
------------------------------------------------------------------


GetExpirationFieldID() is c# method which simply returns diffrent id for Expiration field. i.e we are associating jscalendar with each gridview row by uniqe id.

// in Code behind file.incrementing counter
   in "GridView_RowDataBound" event.

  public string GetExpirationFieldID()
    {
        return "txtExpDate" + counter;
    }

Thanks
Maulik






Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding DropDownList in gridview template hughworm BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 0 October 15th, 2008 11:16 AM
Generating Textboxes with the GridView Template yes_no ASP.NET 2.0 Professional 3 September 13th, 2008 07:48 AM
Get GridView Cell Value Based on GridView Column stublair C# 2008 aka C# 3.0 0 September 4th, 2008 08:30 AM
Need to get value of gridview template columns for kmh030 ASP.NET 2.0 Professional 1 January 6th, 2007 11:10 PM
template column and bound column hidayah ASP.NET 1.x and 2.0 Application Design 1 April 9th, 2005 03:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.