Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with AjaxControlToolkit CalendarExtender with TextChanged in a datagrid.

Problem with AjaxControlToolkit CalendarExtender with TextChanged in a datagrid.

Scheduled Pinned Locked Moved ASP.NET
cssdesignsysadmindockerhelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thomasa
    wrote on last edited by
    #1

    I have a datagrid with an CalendarExtender conected to a TextBox in a DataGrid asp:datagrid id="dgSubscription" runat="server" CssClass="grid" AllowPaging="False" CellPadding="0" GridLines="Vertical" AutoGenerateColumns="False" ShowFooter="true" OnItemCreated="dgSubscription_ItemCreated"> Columns> asp:TemplateColumn HeaderText="Date" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="150px"> ItemTemplate> asp:TextBox ID="tbDtmStart" runat="server" AutoPostBack="true"></asp:TextBox> <cc1:CalendarExtender ID="ceStart" runat="server" Format="dd.MM.yyyy" TargetControlID="tbDtmStart" SelectedDate='<%#(DateTime)DataBinder.Eval(Container.DataItem, "dtmStart")%>'> </cc1:CalendarExtender> I have an on item created in the code behind, hver I add a TextChanged event to the Date TextBox protected void dgSubscription_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { try { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // Start date tb = (System.Web.UI.WebControls.TextBox)e.Item.FindControl("tbDtmStart"); tb.TextChanged += new EventHandler(this.OnSubscriptionDtmStartChanged); ..... At first time the page load, the DataGrid.DataSource gets it values from a dataview. The problem is that the OnSubscriptionDtmStartChanged is triggerd for every row in the DataGrid, because the CalendarExtender changes the TextBox's value. There is allso a problem that the OnSubscriptionDtmStartChanged funtion i triggered 2 times when I change the value on one of the DataGridRow. I know that all of this has to do with the CalendarExtender changes the TextBox's value, but can I some how get around this? Thanks Thomas

    T 1 Reply Last reply
    0
    • T thomasa

      I have a datagrid with an CalendarExtender conected to a TextBox in a DataGrid asp:datagrid id="dgSubscription" runat="server" CssClass="grid" AllowPaging="False" CellPadding="0" GridLines="Vertical" AutoGenerateColumns="False" ShowFooter="true" OnItemCreated="dgSubscription_ItemCreated"> Columns> asp:TemplateColumn HeaderText="Date" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="150px"> ItemTemplate> asp:TextBox ID="tbDtmStart" runat="server" AutoPostBack="true"></asp:TextBox> <cc1:CalendarExtender ID="ceStart" runat="server" Format="dd.MM.yyyy" TargetControlID="tbDtmStart" SelectedDate='<%#(DateTime)DataBinder.Eval(Container.DataItem, "dtmStart")%>'> </cc1:CalendarExtender> I have an on item created in the code behind, hver I add a TextChanged event to the Date TextBox protected void dgSubscription_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { try { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // Start date tb = (System.Web.UI.WebControls.TextBox)e.Item.FindControl("tbDtmStart"); tb.TextChanged += new EventHandler(this.OnSubscriptionDtmStartChanged); ..... At first time the page load, the DataGrid.DataSource gets it values from a dataview. The problem is that the OnSubscriptionDtmStartChanged is triggerd for every row in the DataGrid, because the CalendarExtender changes the TextBox's value. There is allso a problem that the OnSubscriptionDtmStartChanged funtion i triggered 2 times when I change the value on one of the DataGridRow. I know that all of this has to do with the CalendarExtender changes the TextBox's value, but can I some how get around this? Thanks Thomas

      T Offline
      T Offline
      thomasa
      wrote on last edited by
      #2

      The problem was that I binded the Date to the CalendarExtender as: <cc1:CalendarExtender ID="ceStart" runat="server" Format="dd.MM.yyyy" TargetControlID="tbDtmStart" SelectedDate='<%#(DateTime)DataBinder.Eval(Container.DataItem, "dtmStart")%>'> All of my problems went away when I insted: asp:TextBox ID="tbDtmStart" runat="server" Text='<%#((DateTime)DataBinder.Eval(Container.DataItem, "dtmStart")).ToString("dd.MM.yyyy")%>' AutoPostBack="true"></asp:TextBox> <cc1:CalendarExtender ID="ceStart" runat="server" Format="dd.MM.yyyy" TargetControlID="tbDtmStart"> </cc1:CalendarExtender> Thomas

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups