Get An Error A String (selected Category In The Ddl) Cannot Be Converted To A Category Object?

Feb 7, 2010

I'll try to explain as simple as I can in text what my problem is. I don't see any other way to make my issue clear.

I have a GridView that uses an ObjectDataSource.

The ObjectDataSource has an DataObjectTypeName defined, so I pass/get complete objects or list of objects to/from the data access methods.

The objects I'm working with, let's say we work with Book objects, contain a Title and a Category, BUT the Category is an object itself. When the Select method is called, we get a List of Book objects, which is perfectly displayed, overridden ToString method in the Category objects within the Book objects.

The problem I face is that I can't find a way to update the category in my GridView. What I did already accomplish is:I used a template field in the GridView for the Category so I could use a DropDownList for that field in Edit mode.

I bound the DropDownList to another ObjectDataSource that gives me a list of CategoryObjects.

So when I enter Edit mode... the row shows a nice ddl with the available categories. It even selects the right original category.

So far so good... but when I want to save my new selection, I get an error that a string (the selected category in the ddl) cannot be converted to a Category object (that's what the Book object, that is going to be used for the update, expects).

View 5 Replies


Similar Messages:

ADO.NET :: Entity Framework 3.5 / Select Category From Dropdownlist Bind Gridview To All Products Related To This Category?

Nov 5, 2010

i create example using Northwind database so i create a new website and add new ADO.Net Entity Data Model (.edmx) called Northwind.edmx and i add Categories and Products table inside this (.edmx) file

and add new ADO.Net Data Servuce called "ADODataService" and add it as WebReferences called NorthwindService

so i add new web page and drag DropdownList and Gridview as i want to bind Dropdownlist to all categories and when i select category from Dropdownlist bind Gridview to all Products related to this category

so my code

[Code]....

and my code
[Code]....

so when i select category from Dropdownlist nothing happen :(

also you will find commented code in method BindCategory whuch is not work also.

View 1 Replies

Forms Data Controls :: How To Display Category Name Without Category Id

Mar 30, 2011

I am working in a project that is a musical website. I want to display the web page with all categories I have. In my database , named Category_Master, I have two fields like Category_Id (which is a primary key ) and Category_Name. I have generated category_Id with NEWID() function. The category_Id is not supposed to display on the web page. But, i have to select Category_Name and according to that , I have to get the category_Id. If I am using Static connection with SqlDataSource, i am able to make visible=false property so that the category_id won't be visible. But , at that time, I can't write code to Select the category_id of the selected index.

If i am using disconnected approach, I filled the dataset with the Category_Master, and binded it to GridView. But, at that time, I can't hide the category_id from the user. I want to select category_id by clicking on the category_name with out displaying category_id ..?

View 4 Replies

Forms Data Controls :: Show Certain Input Fields Depending On Category Selected?

Mar 21, 2010

What would be the best way to handle the following scenario? I have an application where depending on what type of proceeding is selected, only certain input fields should be visible.

There are 33 proceeding types and 14 input fields in total

First case, make one big form with all of the fields and have a dropdown with proceeding type which depending on what is selected, makes certain fields visible?

View 5 Replies

Web Forms :: Nhibernate Association / Not Set To An Instance Of Object At The Line "category.Products.Add(product);"

Apr 19, 2010

I am using nhibernate and performing one to many relation,

i have a parent table "Category" and child table as "product"

this is my code,

category.CategoryID = txtcategoryid.text;
category.CategoryName = txtName.Text;
category.CategoryDescription = txtDescription.Text;
product.CategoryID = category;
product.ProductName = txtProductName.Text;
product.ProductID = txtProductID.Text;
product.ProductDescription = txtProductDescription.Text;
category.Products.Add(product);
DAO.CanAddCategory(category);

but it throws exception, object reference not set to an instance of object at the line "category.Products.Add(product);"

View 9 Replies

Web Forms :: Error Connection From Category List To Product List?

Dec 9, 2010

<a href='<%# VirtualPathUtility.ToAbsolute("~/ProductsList.aspx?CategoryId=" + Eval("CategoryID")) %>'><%# Eval("CategoryName") %></a>

it bring me this error Conversion from string "~/Products.aspx?CategoryId=" to type 'Double' is not valid.

View 1 Replies

MVC :: How To Display Category Name Instead Of CategoryID

Sep 18, 2010

I have class Item & Category

[Code]....

How can I display Category Name? Do I have to add CategoryName into Item class and bind it on aspx page or is there something similar to Html.DropDownList?

[Code]....

View 2 Replies

Web Forms :: How To Filter A Category

Jan 11, 2011

we are currently running a website in which the home page has recent tab section which contains list of category list i need to block a category.

View 1 Replies

MVC :: How To Add Product To Category (Many-to-many Relation)

Feb 16, 2011

I'm trying to add a product to one or more categories, but I'm going nowhere slow.

Table layout:

[Code]....

[Code]....

[Code]....

I been trying everything to add a product to a category, but without luck. I would have though this was the "right" way:

[Code]....

On my "Create" product page, the product is created but I just can't find a way to link a product to one or more categories. It just skips back to the Create page, even though I have put a Redirect in the Controller.

View 12 Replies

URL Routing With Category Variable?

Mar 16, 2011

I just learned routing and basic routing works, like /topics/people but I am not having any luck implementing like topics/people/{id} or any other variable. It just won't show.

So how do I go and fill that id from a listbox? I googled and people did it without even doing any coding, or did they skip that step? my listbox is in my master page and content pages will use that listbox value in their url too. And then later on I'll add username and stuff too. so for now I just want to know how to set that variable to my listbox. This is what I have for testing:

void RegisterRoutes(RouteCollection routes)

[Code].....

View 7 Replies

How To Change Order In Category

Jun 17, 2010

I am buiding web application about news.My problem i need to change order of articles in that category.
Example :

+ Article A ----> position 1
+ Article B ----> position 2
+ Article C ----> position 3
+ Article D ----> position 4
+ Article E ----> position 5
+ Article F ----> position 6

All articles A -> F are inside category. Sometime i want to Article E is position 1, or article C in position 6 ...and so on Now i can't imagine what i have to do ?

View 9 Replies

Access :: How To Show Category And Forum

Aug 25, 2010

I would like to make script that show category and all its forum that 's why I have created table 'cat' ( id , CAT_TITLE )( table for category) and an other table for forum name ' s 'forum' ( id , name,CAT_ID)

my question how I can show category and the forum by using repeater or another control like http://forums.asp.net/

View 2 Replies

ADO.NET :: Retrieve Records In Category - Basic SQL Way?

Sep 9, 2010

I have the following code that retrieves a bunch of records in a category, but I need it to retrieve them in a basic SQL way with a WHERE and ORDER BY.

var people = FnesseFitness.Categories.Include("People").Single(g => g.CategoryName == category

View 4 Replies

C# - How To Implement A Category Hierarchy Using Collections

Apr 14, 2010

I have about 200 categories that are nested. I am currently reading the documention on the C5 generics library. I am not sure if the C5 library is overkill or not. I am looking at converting all my custom algorithms to the C5 implemention.

This is what I need. If a certain category is chosen i need to find its parents, siblings, direct children, and all children.

This is the way I have it set up. To find the:

Parents: I start from the current location then loop through the list and find the current parent. When I find the parent I loop through the whole list again to find the next parent and so on.

Siblings: I loop through the whole list and find all the nodes that have the same parent as the choosen node.

direct children: I loop through the whole list and find all nodes that is a parent of the choosen node.

All Children: This one took me a while to figure out. But I used recursion to find all children of the choosen node.

View 1 Replies

Web Forms :: Databind CheckboxList By Category?

Jun 3, 2010

I'm databinding the checkbox list to a db table which has a category assigned for multiple records. I can list the checkbox but I can't sort them by category using the checkbox list control. Can somebody post an example on how to achieve this? Category 1chk Record 1 chk Record 2 chk Record 3Category 2chk record 4 chk record 5 Etc

View 3 Replies

C# - Order A List / No Other Fields Associated With A Category?

Oct 26, 2010

I have a function in sitefinity that returns a list of categories.

//return list of categories
private IList<ICategory> GetCategoryDataSource() {
var cntManager = new ContentManager(CaseStudyManager.DefaultContentProvider);
IList allCategories = cntManager.GetCategories();
List<ICategory> filteredList = new List<ICategory>();
foreach (ICategory category in allCategories) {
filteredList.Add(category);
}
return filteredList;
}

What I want to know is how to sort this list.

Categories in Sitefinity are as far as i can tell just a string, there are no other fields associated with a category. Therefore I have nothing to sort the categories on, other than appending each category with a number, like:

1 - Legal
2 - Financial
3 - Property

When these categories are displayed on the website I can then at least trim the parts i need.

View 2 Replies

Autodetect The Category Depending On ReferenceMappingExpression?

Sep 14, 2010

I have following entities: Every time i update or insert a transaction i would like to autodetect the category depending on ReferenceMappingExpression or DescriptionMapppingExpression in CategoryMappings Entity. I mean i want to match Transaction.Description to CategoryMappings.DescriptionMapping and if it matches get the FkCategoryID from CategoryMapping and save the transactions. It is possible to loop throug every transaction in list and categorymapping list but i dont think its good idea.

View 1 Replies

Web Forms :: Image Gallery By Category?

Jan 25, 2013

I want to make Image Gallery for products By Category

for example clothes, books,...

I want doing it with the two links

Image-Gallery-using-ASP.Net-DataList-Control-Part-I
Image-Gallery-using-ASP.Net-DataList-Control-Part-II

without Category it works fine

but I changed this line 

FROM tbl_product ) AS tbl WHERE Row >= '
to
FROM tbl_product ) AS tbl WHERE cat_id=@cat_id Row >= '
andI added

[Code]....

and now I face this messageProcedure or function spx_Pager has too many arguments specified.

View 1 Replies

Web Forms :: Put 4 Category On Axis X Of LineChart

May 7, 2015

I would like to put 4 categories (fixed) on my chart (example: 1,2,3,4 quarter on the x-axis) and display data from the database in the right category.

// AVG correspond à moyenne et on multiplie par 100 puisque à la base la colonne est de type Decimal
string query = string.Format("select Entite, AVG(AvancementQuantitatifT1 * 100) FROM reponse WHERE ObjectifStrategique = '{0}' GROUP BY Entite", Objectif_strategique.SelectedItem.Value);

[Code]..... 

For example I want to do something like that :

select Progressquarter1, Progressquarter2,Progressquarter3, Progressquarter4 and put respectively in quarter 1 quarter 2 quarter 3 and quarter 4.

View 1 Replies

How To Create Category And List In One Query With Linq

Jun 20, 2010

I want to create something like this using a DataList and Flow markup:

|-----------------------|
| Title |
|-----------------------|
| [x] Title |
| [x] Title |
| ... |
-------------------------

I have a table (modeled in Linq2Sql) Foo that has these fields

int id;
int? parentId;
string title;
Foo Parent;
EntitySet<Foo> Children;

Now, when there is a null parent, it means it's a top level category, and if the parent has a value, it's part of the category list.

I have created a DataList, and used a LinqDataSource with a query that looks like this:

[Code].....

This obviously doesn't work. How can I utilize the Children collection in a repeater of a DataList item?

View 1 Replies

Architecture :: How To Configure Database Design When Add A Sub Category

Apr 24, 2010

I have a ordinary Category/Product database relationship Design structure.

Now i wish to add a sub category to this architecture.

for example, Cloths Category needs to be sub divided - Women,Men,Children categories.Also what about other Ctegories such as: Car,this also has sub divisions: Model,Type.

My Products table contains ProductName field together with generic field for Size,Colour and Price fields.

How do you therefore incorporate this sub division into the existing Category/Product relationship model and is there a model example?

View 7 Replies

MVC :: Create Routing - Products/Category/Electronics?

Jul 27, 2010

i have a product page that can potentially take in the following optional query string params:

Category, OrderBy, Page

How do I create my route so the urls show up like this:

Products/Category/Electronics

Products/Category/Electronics/OrderBy/Price

Products/Category/Electronics/OrderBy/Price/Page/1

basically, im trying to not use the ? for my query string params.

View 1 Replies

SQL Server :: Getting Latest Date And Associated Data For Each Category?

Jan 18, 2011

How do I get each category, with the latest date and the number associated with that record

SELECT
Category,EntryDate, Number
FROM MyTable

View 4 Replies

Forms Data Controls :: Add A Sub Category To A Gridview?

Apr 26, 2010

I'm working on a dynamic table of contents (toc). The toc is generated from data in a sql database. There are 5 sections in the toc and within each of the five sections, there are a varied number of rows. (Section 1 may have 5 rows, while Section 2 has 12 rows). To help differentiate between the sections, I'd like the ability to add some type of grouping in my gridview. So, it would look like below. Do I just add a different gridview for each section, or is there a way to "categorize" the gridview to break up the data with a Section 1 Category

a
b
c
d
e

Section 2 Category
a
b
c
d
e
f
g
h
i....

View 3 Replies

ADO.NET :: Linq To SQL Group By Category And Count Each Subcategory?

Sep 30, 2010

I am wonder how I can generate a result table from linq to sql as below

Car sales table
Toyota small
Toyota passenger
Toyota small
Honda small
Honda small
Honda passenger
Honda small

result table
Brand small passenger total
Toyata 2 1 3
Honda 3 1 4

GridView1.DataSource = (from dtCarSales.AsEnumerable() .....

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved