Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

process calendar days without an event

Status
Not open for further replies.

smsinger3

Programmer
Oct 5, 2000
192
0
0
US
Hello all. This problem is stumping me. I created a calendar with a dropdown box for each day. The user needs to select a name for that day.

When they are done selecting all the names for that month, I want them to they click a submit button on the bottom of the form where I want to write code to save each date they selected to a database. My problem is that I don't know how to read each cell of the calendar and then look at the dropdown list. I've googled this and tried other sources, but I am nowhere. Does anyone have any ideas???

I realize that I could save the data after they selected each name, but I only want to open the database once.

Does all this make sense? Your help is greatly appreciated!!

Thanks,

smsinger
smsinger3@yahoo.com



I need to read each day
 
I think I have done something similar to this myself.

You have an asp:table with each cell representing a day and also containing a dropdown. Your users select something from the dropdowns in particular cells and you want to read this selected info back at the server.

You can iterate through your table cells using its Rows and Cells collections. For each cell check that it contains controls (in its Controls collection) your drop down should be Control[0] - copy this with casting ie. [DropDownList mydropdown = (DropDownList) myTable.Rows[y].Cells[x].Controls[0]] - you can then use mydropdown to access the value of this cells dropdown - build up a list and write them to your db using a transaction.

I hope I understood the question right!

Cheers...
 
That sounds like a great idea. However, I can't figure out the line of code to get to the table cells within the calender table. Any help is certainly appreciated!

Thanks,

SteveS
 
If your table is a webform control Table - called myTable then its Rows collection is accessed with myTable.Rows[y] where y is the required row in the table. The cells are accessed for each row with myTable.Rows[y].Cells[x] where x is the required column.

If this is not clear are you doing this at the server? and are you using basic or c#?

Cheers,

Gary



 
I am using a calendar control defined like this on my .aspx page:
<asp:Calendar id=&quot;cal&quot; runat=&quot;server&quot;></asp:Calendar>

I add each dropdown box in the cal_DayRender(..) event using VB.NET. Here is the code:

ctlCell = e.Cell
ctlCell.VerticalAlign = VerticalAlign.Top
ctlCell.HorizontalAlign = HorizontalAlign.Center
ctlCell.Controls.Add(New LiteralControl(&quot;<br>&quot;))
ctlCell.Controls.Add(drpUserName)
ctlCell.Controls.Add(New LiteralControl(&quot;<br>&quot;))


When the user is done with the screen. She will click the Save button and I want to code a sub to take each drpUserName and insert it into a table. I'm not sure how to access the table cells for each day. How do I do this?


 
OK - I never used the Calendar control before.

Having quickly looked at it, it appears the only collection is the Control collection - so iterate through this and it might just contain all your dropdowns in the order that you inserted them - you never know!

Same applies with this - copy/cast each control in controls collection to ListBox control and you should be able to read its selection.

Cheers,

Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top