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.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
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?
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
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.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
milindsarasw...
Member
436 Points
545 Posts
Custom Webpart and FormView Issue
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) { fvLeaveForm.DataBind(); 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); } }superguppie
All-Star
48225 Points
8679 Posts
Re: Custom Webpart and FormView Issue
Feb 21, 2012 03:09 PM|LINK
How do you DataBind the DropDownList?
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
milindsarasw...
Member
436 Points
545 Posts
Re: Custom Webpart and FormView Issue
Feb 21, 2012 07:00 PM|LINK
With SQLDataSource
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: Custom Webpart and FormView Issue
Feb 22, 2012 07:29 AM|LINK
Hi,
Try to remove the DataBind() line for fvLeaveForm in at the first line of DataChanged event.
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
milindsarasw...
Member
436 Points
545 Posts
Re: Custom Webpart and FormView Issue
Feb 22, 2012 08:09 AM|LINK
No it is same. I did what you suggested
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: Custom Webpart and FormView Issue
Feb 23, 2012 02:06 AM|LINK
Hi,
How do you bind FormView? If you bind it with custom data source in code, then add postback checking block around it.
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
milindsarasw...
Member
436 Points
545 Posts
Re: Custom Webpart and FormView Issue
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.
superguppie
All-Star
48225 Points
8679 Posts
Re: Custom Webpart and FormView Issue
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?
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
milindsarasw...
Member
436 Points
545 Posts
Re: Custom Webpart and FormView Issue
Feb 24, 2012 02:08 PM|LINK
Yea I amusing .Net 3.5
superguppie
All-Star
48225 Points
8679 Posts
Re: Custom Webpart and FormView Issue
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.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.