Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 27, 2012 04:32 PM by milindsaraswala
Feb 20, 2012 02:36 PM|LINK
I am creating webaprt in VS 2010 with C# code. In my webpart there is FormView control and it always remain in Insert mode. In Insert mode there is DropDown Control and SharePoint DateTime Control. I have writen some code on SharePoint DateTime Control DateChanged event.
And DateTime control is autopostback.
Now Issue when DateChange event is fired and autopost back is done It should send selected Date from DateTime Control and also send selected value from DropDown. But when DateTime Autoback is done DropDown is sending First Item Value rather to selected one.
Following is my code. Kindly somebody can help me.
protected void dtStartDate_DateChanged(object sender, EventArgs e)
DateTimeControl dtStartDate = (DateTimeControl)fvLeaveForm.FindControl("dtStartDate");
DropDownList dpLeaveType = (DropDownList)fvLeaveForm.FindControl("dpLeaveType");
if (dtStartDate.SelectedDate != null)
Label lblLeaveBalance = (Label)fvLeaveForm.FindControl("lblLeaveBalance");
lblLeaveBalance.Text = LeaveBalance(dtStartDate.SelectedDate,dpLeaveType.SelectedValue);
Feb 21, 2012 03:09 PM|LINK
How do you DataBind the DropDownList?
Feb 21, 2012 07:00 PM|LINK
Feb 22, 2012 07:29 AM|LINK
Try to remove the DataBind() line for fvLeaveForm in at the first line of DataChanged event.
Feb 22, 2012 08:09 AM|LINK
No it is same. I did what you suggested
Feb 23, 2012 02:06 AM|LINK
How do you bind FormView? If you bind it with custom data source in code, then add postback checking block around it.
Feb 23, 2012 02:22 AM|LINK
No I am binding it with SQL Data Source. I forget to tell you I am using Oracle as Database and Odp.net.
And frustrating is that if I use without formview then it will preserve value on all postback.
Feb 24, 2012 11:25 AM|LINK
So, if you put the DropDownList outside the FormView, that works? Hmmmmm, I remember ListView having that problem in 4.0. What version of .NET are you using?
Feb 24, 2012 02:08 PM|LINK
Yea I amusing .Net 3.5
Feb 27, 2012 01:59 PM|LINK
Too bad I can't try SharePoint myself. The DateTimeControl does seem suspect.
What you could do to debug this is handle the DataBinding event of the DropDownList. Put a breakpoint in it, and use the debugger to see if it gets DataBound when the DataTimeControl.DateChanged fires. The DataBind that was originally in there was definitely
a suspect. See if there is another.
If the DropDownList is DataBinding again, see if the stack trace reveals what line of code does that.