Calendar control - adding a textbox on each day for data entry

Discussion in 'ASP .Net Web Controls' started by Keith-Earl, Oct 22, 2004.

  1. Keith-Earl

    Keith-Earl Guest

    Is it feasible to add a simple textbox into the cell (day) of a calendar
    control? How would I add it? access it once the user hit Submit?

    I searched google with ".net calendar control data entry" and got lots of
    but none allowed for data entry from within the cell.

    Thanks,

    Keith
     
    Keith-Earl, Oct 22, 2004
    #1
    1. Advertisements

  2. Keith-Earl

    rc Guest

    Hello,



    I am currently working on a project that needs similar capability.



    Here is how I accomplished the first part:





    Sub Calendar_RenderDay(s as object, e as DayRenderEventArgs)

    dim lb=new label()
    dim tb=new TextBox()

    lb.text="<center><b>" & Day(e.day.date) & "</b><BR>"

    tb.id="Day" & Day(e.day.date)
    tb.columns="2"
    tb.maxlength="3"

    e.Cell.Controls.Clear()
    e.Cell.Controls.Add(lb)
    e.Cell.Controls.Add(tb)

    end sub





    This, of course, runs from the RenderDay method of the Calendar control.





    The second part, I'm still working on. I believe it will entail somehow
    using the FindControl function.



    I have not quite figured it out yet.



    Hope this helps.
     
    rc, Oct 23, 2004
    #2
    1. Advertisements

  3. RC,

    I figured out the first part, just need to figure out how to iterate through
    each day (cell) once a submit button is pushed. We could use the
    button_clicked event, just how to iterate thru the cells.

    Thanks,
    Keith
     
    Keith A. Rowe, Oct 25, 2004
    #3
  4. Keith-Earl

    Keith-Earl Guest

    I figured it out!

    You have to assign an ID to the text box and also add a hidden text box that
    contains the date. Assign an ID to the hidden field as well. Make sure you
    wrap the Calendar in <form> tags.

    The POST will create an array of controls for you, each named the same,
    but you can put it in an array and process them. I will post the code if
    you like.

    Keith
     
    Keith-Earl, Oct 26, 2004
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.