Click here to Skip to main content
15,877,637 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Friends,

My Class Model
Public Class Channel
   public int ChannelId {get;set;}
   public string ChannelName {getlset;}
   public string ChannelCode {get;set;}

While create method run, I silent property named ChannelId by doing


Somewhare I want to add again ChannelId or any property what should I do?

Even, I know. . this command.

ModelState.Add(...) but not working. .

Please. . Guide me.
Updated 5-Aug-14 1:26am

You cannot modify the model dynamically since this would also require modifying the underlying data store, possibly destroying information in the process.

There really isn't a good reason to do this so what are you really trying to do with this?
Share this answer
Manoj B. Kalla 5-Aug-14 8:41am    
Dear Dave,

I want to add a new property like

public string ChannelArea {get;set;}

and want used in EDIT view only.

For this I want to create a new model again. But I want to add new property runtime. For this what should I do.
Dave Kreskowiak 5-Aug-14 12:43pm    
I think you REALLY need to pickup a book on MVC and work through it.

You NEVER modify your Model classes just to pass them to the View. You create ViewModel classes that take the information from the Model classes and any additional data the View may need to display/edit the data.
Manoj B. Kalla 6-Aug-14 3:25am    
Dear Dave Kreskowiak sir,

I searched and got my answer.

Thanks for your answers.
Dave Kreskowiak 6-Aug-14 8:25am    
Yeah, about that. Either you've not explained your requirement in enough detail or you're going about this the hard way and will find that it is indeed not the solution you're looking for.

Good luck.
Dear Dave Kreskowiak sir,

I searched and got my answer.

Thanks for your answers.

Answer as per my requirement
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900