But we got a problem,Because the top level category's id is 0(zero),and the SelectOption is "Top Level",and this option dosn't stored int the database(and i don't wanna add a record to database)
So,How could we add an option to that list like(<option value="0">Top Level</option>)
freechoice
Member
115 Points
43 Posts
How to add a select option to HTML.DropDwonList
Aug 27, 2008 09:46 AM|LINK
I am trying to build a form that contain parent category select,but it is a nested table,here is the datatable structure:
CREATE TABLE [dbo].[cms_categories](
[id] [int] IDENTITY(1,1) NOT NULL,
[parent_id] [int] NULL,
[title] [varchar](255) NULL,
[name] [varchar](255) NULL,
[alias] [varchar](255) NULL,
[image] [varchar](255) NULL,
[description] [text] NULL,
[published] [tinyint] NULL,
[checked_out] [int] NULL,
[checked_out_time] [datetime] NULL,
[ordering] [int] NULL,
CONSTRAINT [PK_cms_categories] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
)
In my controller,I use the following code:
ViewData Class
public class CategoryNewViewData { public List ParentCategory { get; set; } }Controller Action
But we got a problem,Because the top level category's id is 0(zero),and the SelectOption is "Top Level",and this option dosn't stored int the database(and i don't wanna add a record to database)
So,How could we add an option to that list like(<option value="0">Top Level</option>)
Anybody who can give me a hand?
thanks a lot