but what if I wanted to bind to collection items within the ViewModel. I'm not sure if it's possible. Here's what I have:
My ViewModel:
[code]....
I'm getting the following error: Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.
I have a DetailsView control which gets data from a IEnumerable custom class. But I can't get updated values from the control so I can process to update them manually in the database. How can I do that?
I have a situation where I need to databind a string array to a CheckBoxList. The decision if each item should be checked, or not, needs to be done by using a different string array. Here's a code sample:
string[] supportedTransports = ... ;// "sms,tcp,http,direct" string[] transports = ... ; // subset of the above, i.e. "sms,http" // bind supportedTransports to the CheckBoxList TransportsCheckBoxList.DataSource = supportedTransports; TransportsCheckBoxList.DataBind();
This binds nicely, but each item is unchecked. I need to query transports, somehow, to determine the checked status. I am wondering if there is an easy way to do this with CheckBoxList or if I have to create some kind of adapter and bind to that?
i have an objectdatasource bound to the System.Web.Security.Roles getAllRoles methods, this method returns an string[] with the names of the roles, then i wanna bind a gridview with this datasource, but it shows me just a one column named length(the length of each role name), how can i instead the length of the string that represent the role name, put the role name?
My Grid is bound to a collection type datasource. When I try to sort the Columns in the Grid I get Javascript error saying sorting event not implemented. Why is the default inbuilt sort functionality not working which worked fine when I directly used a sqlDataSource using smart tag. Do I have to write some code to achieve sorting ?
I'm new to MVC pattern and I have a question regarding to a dropdownlist. Actually My Data came from a collection (random string) then it displays it in a list. And yes it display, so I add a dropdownlist. And I can populate it using the same collection. My question is how can I populate the dropdownlist from different collection?
Now what I need change to in the above code to get the combination of both..otherwise i need have textbox for description which syncs with ddl..which is bit complex for my level of programming.
I have a partial class extending my Entity Model. I'd like to write a method that returns a collection of types from my entity framework model. For example, I'd like to get all the states to populate a drop down list. So I've written a method called getallstates(), similar to the example below:
[Code]....
I tried returning a list of Objects, and a list of states to my calling method to be used to bind to a drop down list. However I get an error that:
Server Error in Application. Unable to cast object of type 'System.Data.Objects.ObjectQuery to type 'System.Collections.Generic.List`1[System.Object]'.
I have an ASCX control which is a special dropdownlist. I add that control dynamically to the page and fill it with data. This control has a postback that will change the contents of a second dynamically created standard dropdownlist.
When I change the selection on the first dropdown, the indexchanged fires and I get new data and attempt to place it in the second dropdownlist's items collection, by first clearing it then filling it with new data.
This works fine the first time a change the selection, but when I select a second time the following error is thrown:
The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.
I'm not adding or removing new controls in the fired event, only changing data. And again, it works the first time, but doesn't subsequent times.
If I disable stateview on the child control, then the control just doesn't get updated with data at all.
I want to bind a dropdownlist to a database. I did the following coding but it isn't working.
using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.Odbc; using System.Data.SqlClient;....
I am getting the error as
at _Default.rebind() in c:Documents and SettingsaMy DocumentsVisual Studio 2008WebSites oolbar1Default.aspx.cs:line 32
bind the dropdownlist to a datasource.I want my dropdownlist to display text from a database column and use the value field for some other purpose later on in code. I am getting the page displayed when i run the project but not able to get the data in dropdownlist
I have a dropdown list which I bind through a datasource. How can I inject a default value to it? My db doesn't have a default value and changes are not permitted!
I'm trying to bind the contents of a node of XML to a Drop Down List without much success. Initially, the whole XML document is bound to a repeater - this works perfectly, but now I need to display a drop down list based on the children in the "" node, but I get Data at the root level is invalid. Line 1, position 1 error message on the DataBind() method on the dropDownList. The code snippet I'm using is:
I have a DropDownList in a DetailsView, which binds a user's 'AllocatedUser' to a user in the Users table. Occasionally, we'll have some mishaps in the database where the user allocated isn't in the users table, which the DropDownList is filled with. In this case the site crashes and we get a 'SelectedValue does not exist in the list of items error'.What I want to do is catch any binding errors like that, and just set the DropDownList index to 0. I've tried something like this:
i have a dropdownlist,which is dynamically binding from the database ............the problem is i want a particular item in the dropdownlist to apper first in the dropdownlist
I need to bind a dropdownlist to multiple column along with the column heading.. the heading should be unselectablesomething similar to thisEach group are in differnet tables..ow can i implement thisits consuming my time..
I have a list of objects that I want to bind to a gridview. Creating that list and binding it works fine for most of the public properties in that list.
There are some objects contained in each of those objects... for instance there is an Address object.
object.Address.Line1;
object.Address.Line2;
When I bind this to my gridview, I have no issues with stuff like object.DateRegistered, but how can I access things like object.Address.WhatEverProperty? I always get this error:
"A field or property with the name 'xxx.xxxx' was not found on the selected data source."
I have 2 dropdown lists on a WebForm. One of them is populated in the page's Page_Load event. This oneworks fine with the following code.
[Code]....
Then, after a value is selected from this list and a date is selected from a DateTime picker, then I click a button which is supposed to populate the 2nd dropdownlist. In the debugger in the button's click event I can see that the dataset is being populated with data, but then the list is never populated after the DataBind() method is run. Here is code from the button's click event.