|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Formview DropDownList bug??I have a page with a formview control who datasource is a objectdatasource.
In edit mode template I have tree dropdownlist; Year, Month and Day. Each dropdownlist i populated from an objectdatasource object and is bind to column in the formview control objectdatasource. The objectdatasource object for dropdownlist Day have 2 arguments; Year and Month. The dropdownlist day is populated with correct number of days for that month and year. When changing Year or Month this error appear: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. If I remove the binding for dropdownlist Day the error doesn’t appear, but then I not able to save the Day Column Is there anybody who can help me? Karl-Inge Reknes Hi Karl-Inge,
I met the same situation in using dependent dropdownlist within the EditItemTemplate where 2-way databinding is attempted. The solution is to remove the 2-way databinding from the dependent dropdownlist and replace it with customized code during processing the ItemUpdating event. For example if one had 2 dropdownlists where one had the country and the other had the City; where the City dropdownlist re-populate every time the Country selection is changed, then upon ItemUpdating I would do something like this: void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) { string strCity= ((DropDownList))((FormView)sender).FindControl("ddlCity")).SelectedValue; e.NewValues[1] = strCity; //assuming the second value being updated is the City e.Cancel = false; //this would confirm that the update should continue } Show quoteHide quote "Karl-Inge Reknes" wrote: > I have a page with a formview control who datasource is a objectdatasource. > In edit mode template I have tree dropdownlist; Year, Month and Day. Each > dropdownlist i populated from an objectdatasource object and is bind to > column in the formview control objectdatasource. The objectdatasource object > for dropdownlist Day have 2 arguments; Year and Month. The dropdownlist day > is populated with correct number of days for that month and year. > > When changing Year or Month this error appear: > > Databinding methods such as Eval(), XPath(), and Bind() can only be used in > the context of a databound control. > > If I remove the binding for dropdownlist Day the error doesn’t appear, but > then I not able to save the Day Column > > Is there anybody who can help me? > > Karl-Inge Reknes > I missed to note that in the solution described below I have used a label
that was 2-way databound to the City instead of the dropdownlist. The label was styled as hidden. Its purpose is to keep the number of e.NewValues to the same as if I had the dropdownlist 2-way databound. Show quoteHide quote "Phillip Williams" wrote: > Hi Karl-Inge, > > I met the same situation in using dependent dropdownlist within the > EditItemTemplate where 2-way databinding is attempted. The solution is to > remove the 2-way databinding from the dependent dropdownlist and replace it > with customized code during processing the ItemUpdating event. > > For example if one had 2 dropdownlists where one had the country and the > other had the City; where the City dropdownlist re-populate every time the > Country selection is changed, then upon ItemUpdating I would do something > like this: > void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) > { > string strCity= > ((DropDownList))((FormView)sender).FindControl("ddlCity")).SelectedValue; > e.NewValues[1] = strCity; //assuming the second value being updated is > the City > e.Cancel = false; //this would confirm that the update should continue > } > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "Karl-Inge Reknes" wrote: > > > I have a page with a formview control who datasource is a objectdatasource. > > In edit mode template I have tree dropdownlist; Year, Month and Day. Each > > dropdownlist i populated from an objectdatasource object and is bind to > > column in the formview control objectdatasource. The objectdatasource object > > for dropdownlist Day have 2 arguments; Year and Month. The dropdownlist day > > is populated with correct number of days for that month and year. > > > > When changing Year or Month this error appear: > > > > Databinding methods such as Eval(), XPath(), and Bind() can only be used in > > the context of a databound control. > > > > If I remove the binding for dropdownlist Day the error doesn’t appear, but > > then I not able to save the Day Column > > > > Is there anybody who can help me? > > > > Karl-Inge Reknes > > Thanks Phillip.
Karl-Inge Show quoteHide quote "Phillip Williams" wrote: > I missed to note that in the solution described below I have used a label > that was 2-way databound to the City instead of the dropdownlist. The label > was styled as hidden. Its purpose is to keep the number of e.NewValues to > the same as if I had the dropdownlist 2-way databound. > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "Phillip Williams" wrote: > > > Hi Karl-Inge, > > > > I met the same situation in using dependent dropdownlist within the > > EditItemTemplate where 2-way databinding is attempted. The solution is to > > remove the 2-way databinding from the dependent dropdownlist and replace it > > with customized code during processing the ItemUpdating event. > > > > For example if one had 2 dropdownlists where one had the country and the > > other had the City; where the City dropdownlist re-populate every time the > > Country selection is changed, then upon ItemUpdating I would do something > > like this: > > void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) > > { > > string strCity= > > ((DropDownList))((FormView)sender).FindControl("ddlCity")).SelectedValue; > > e.NewValues[1] = strCity; //assuming the second value being updated is > > the City > > e.Cancel = false; //this would confirm that the update should continue > > } > > -- > > HTH, > > Phillip Williams > > http://www.societopia.net > > http://www.webswapp.com > > > > > > "Karl-Inge Reknes" wrote: > > > > > I have a page with a formview control who datasource is a objectdatasource. > > > In edit mode template I have tree dropdownlist; Year, Month and Day. Each > > > dropdownlist i populated from an objectdatasource object and is bind to > > > column in the formview control objectdatasource. The objectdatasource object > > > for dropdownlist Day have 2 arguments; Year and Month. The dropdownlist day > > > is populated with correct number of days for that month and year. > > > > > > When changing Year or Month this error appear: > > > > > > Databinding methods such as Eval(), XPath(), and Bind() can only be used in > > > the context of a databound control. > > > > > > If I remove the binding for dropdownlist Day the error doesn’t appear, but > > > then I not able to save the Day Column > > > > > > Is there anybody who can help me? > > > > > > Karl-Inge Reknes > > > You are quite welcome, Karl-Inge. I just managed to put a demo of the
solution I proposed below, with the complete source code, at this link: http://www.webswapp.com/demos/formView1.aspx Show quoteHide quote "Karl-Inge Reknes" wrote: > Thanks Phillip. > > Karl-Inge > > "Phillip Williams" wrote: > > > I missed to note that in the solution described below I have used a label > > that was 2-way databound to the City instead of the dropdownlist. The label > > was styled as hidden. Its purpose is to keep the number of e.NewValues to > > the same as if I had the dropdownlist 2-way databound. > > -- > > HTH, > > Phillip Williams > > http://www.societopia.net > > http://www.webswapp.com > > > > > > "Phillip Williams" wrote: > > > > > Hi Karl-Inge, > > > > > > I met the same situation in using dependent dropdownlist within the > > > EditItemTemplate where 2-way databinding is attempted. The solution is to > > > remove the 2-way databinding from the dependent dropdownlist and replace it > > > with customized code during processing the ItemUpdating event. > > > > > > For example if one had 2 dropdownlists where one had the country and the > > > other had the City; where the City dropdownlist re-populate every time the > > > Country selection is changed, then upon ItemUpdating I would do something > > > like this: > > > void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) > > > { > > > string strCity= > > > ((DropDownList))((FormView)sender).FindControl("ddlCity")).SelectedValue; > > > e.NewValues[1] = strCity; //assuming the second value being updated is > > > the City > > > e.Cancel = false; //this would confirm that the update should continue > > > } > > > -- > > > HTH, > > > Phillip Williams > > > http://www.societopia.net > > > http://www.webswapp.com > > > > > > > > > "Karl-Inge Reknes" wrote: > > > > > > > I have a page with a formview control who datasource is a objectdatasource. > > > > In edit mode template I have tree dropdownlist; Year, Month and Day. Each > > > > dropdownlist i populated from an objectdatasource object and is bind to > > > > column in the formview control objectdatasource. The objectdatasource object > > > > for dropdownlist Day have 2 arguments; Year and Month. The dropdownlist day > > > > is populated with correct number of days for that month and year. > > > > > > > > When changing Year or Month this error appear: > > > > > > > > Databinding methods such as Eval(), XPath(), and Bind() can only be used in > > > > the context of a databound control. > > > > > > > > If I remove the binding for dropdownlist Day the error doesn’t appear, but > > > > then I not able to save the Day Column > > > > > > > > Is there anybody who can help me? > > > > > > > > Karl-Inge Reknes > > > > Phillip,
Have you considered posting a DetailsView version of the code on your web site. I am having a devil of a time getting a dependent ddl to work. I have tried all kinds of variations. My latest version I tried putting the <asp:sqldatasource> 's underneath the EditTemplate (and InsertTemplates) for each ddl (1 & 2), but ASP.net is complaining that the control can not be found. Any help would be greatly appreciated. David Show quoteHide quote "Phillip Williams" wrote: > You are quite welcome, Karl-Inge. I just managed to put a demo of the > solution I proposed below, with the complete source code, at this link: > http://www.webswapp.com/demos/formView1.aspx > > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "Karl-Inge Reknes" wrote: > > > Thanks Phillip. > > > > Karl-Inge > > > > "Phillip Williams" wrote: > > > > > I missed to note that in the solution described below I have used a label > > > that was 2-way databound to the City instead of the dropdownlist. The label > > > was styled as hidden. Its purpose is to keep the number of e.NewValues to > > > the same as if I had the dropdownlist 2-way databound. > > > -- > > > HTH, > > > Phillip Williams > > > http://www.societopia.net > > > http://www.webswapp.com > > > > > > > > > "Phillip Williams" wrote: > > > > > > > Hi Karl-Inge, > > > > > > > > I met the same situation in using dependent dropdownlist within the > > > > EditItemTemplate where 2-way databinding is attempted. The solution is to > > > > remove the 2-way databinding from the dependent dropdownlist and replace it > > > > with customized code during processing the ItemUpdating event. > > > > > > > > For example if one had 2 dropdownlists where one had the country and the > > > > other had the City; where the City dropdownlist re-populate every time the > > > > Country selection is changed, then upon ItemUpdating I would do something > > > > like this: > > > > void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) > > > > { > > > > string strCity= > > > > ((DropDownList))((FormView)sender).FindControl("ddlCity")).SelectedValue; > > > > e.NewValues[1] = strCity; //assuming the second value being updated is > > > > the City > > > > e.Cancel = false; //this would confirm that the update should continue > > > > } > > > > -- > > > > HTH, > > > > Phillip Williams > > > > http://www.societopia.net > > > > http://www.webswapp.com > > > > > > > > > > > > "Karl-Inge Reknes" wrote: > > > > > > > > > I have a page with a formview control who datasource is a objectdatasource. > > > > > In edit mode template I have tree dropdownlist; Year, Month and Day. Each > > > > > dropdownlist i populated from an objectdatasource object and is bind to > > > > > column in the formview control objectdatasource. The objectdatasource object > > > > > for dropdownlist Day have 2 arguments; Year and Month. The dropdownlist day > > > > > is populated with correct number of days for that month and year. > > > > > > > > > > When changing Year or Month this error appear: > > > > > > > > > > Databinding methods such as Eval(), XPath(), and Bind() can only be used in > > > > > the context of a databound control. > > > > > > > > > > If I remove the binding for dropdownlist Day the error doesn’t appear, but > > > > > then I not able to save the Day Column > > > > > > > > > > Is there anybody who can help me? > > > > > > > > > > Karl-Inge Reknes > > > > >
VS2005 is a PIECE of Garbage and is bug Ridden
drop down list box - client side code won't execute OnSelectedIndexChange validation summary not always showing message box DataGrid and ViewState Display an images in Datagrid uniqueidentifier and updating record ObjectDataSource .net 2.0 client side access. Why usercontrol won't allow Request.Cookies Pls help me |
|||||||||||||||||||||||