Click here to Skip to main content
16,004,991 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Ajax help is needed Pin
Abhishek Sur31-Aug-08 9:52
professionalAbhishek Sur31-Aug-08 9:52 
AnswerRe: Ajax help is needed Pin
Gayani Devapriya31-Aug-08 17:40
Gayani Devapriya31-Aug-08 17:40 
Questionupdate database from a querystring data Pin
highjo30-Aug-08 8:11
highjo30-Aug-08 8:11 
AnswerRe: update database from a querystring data Pin
Gayani Devapriya31-Aug-08 18:05
Gayani Devapriya31-Aug-08 18:05 
QuestionShared code behind class Pin
Brady Kelly30-Aug-08 5:28
Brady Kelly30-Aug-08 5:28 
Questionfirefox vs IE newline Pin
Sunday8PM30-Aug-08 0:38
Sunday8PM30-Aug-08 0:38 
AnswerRe: firefox vs IE newline Pin
Sunday8PM30-Aug-08 21:43
Sunday8PM30-Aug-08 21:43 
QuestionHow Could we use Html.TextBox("Title",(string)ViewData["title"]??ViewData.Model.Category.title) under MVC framework Pin
freechoice29-Aug-08 23:32
freechoice29-Aug-08 23:32 
Hi,all:
Monthes before,Microsoft distributed the first MVC framework preview version,and 2 days before,MS give the the 5th preview version,My project is under VS2008+SP1+MVC framework preview 5

Here is my controller:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CMS.Models;
using CMS.Views;
using System.Web.Routing;

namespace CMS.Controllers
{
using CMSModel;
[Authorize]
public class CategoryController : Controller
{
private CategoryListDataContext database = new CategoryListDataContext();
CategoryRepository repository;
public CategoryController()
: this(new CategoryRepository(new CategoryListDataContext()))
{
}

public CategoryController(CategoryRepository context)
{
this.repository = context;
}

[HandleError]
public ActionResult Index()
{
ViewData["Title"] = "Category Manager";
ViewData["Message"] = "Category Manager";
var categoryList = from t in database.cms_categories
orderby t.id
select t;
ViewData["Category"] = categoryList;
return View(categoryList.ToList());
}


public ActionResult Edit(int id)
{
CategoryEditViewData viewData = new CategoryEditViewData();
cms_categories category = repository.Categories.SingleOrDefault(c => c.id == id);
if (TempData.ContainsKey("ErrorMessage"))
{
foreach (var item in TempData)
{
ViewData[item.Key] = item.Value;
}
}
ViewData["ParentCategory"] = new SelectList(repository.Categories.ToList(), "id", "name", ViewData["id"] ?? category.id);
ViewData["content"] = category.description;
return View("Edit",viewData);
}
public ActionResult Delete()
{
return View();
}

public ActionResult Publish()
{
return RedirectToAction("Index");
}

public ActionResult UnPublish()
{
return RedirectToAction("Index");
}
}
}

Models:

CategoryRepository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CMS.Models
{
public class CategoryRepository
{
CategoryListDataContext dataContext = null;

public CategoryRepository()
{

}

public CategoryRepository(CategoryListDataContext dataContext)
{
this.dataContext = dataContext;
}

public virtual IQueryable<cms_categories> Categories
{
get {
return this.dataContext.cms_categories;
}
}

public virtual void SubmitChanges()
{
this.dataContext.SubmitChanges();
}

public virtual void InsertCategoryOnSubmit(cms_categories p)
{
this.dataContext.cms_categories.InsertOnSubmit(p);
}
}
}

and CategoryViewData.cs
using System;
using System.Collections.Generic;

namespace CMS.Models
{
public class CategoryEditViewData
{
public cms_categories Category { get; set; }
public List<cms_categories> ParentCategory { get; set; }
}

public class CategoryNewViewData
{
public List<cms_categories> ParentCategory { get; set; }
}
}

and here is part of the code of the view page for EDIT
]]>

Problem is I can't use ViewData.Model.Category........

So anybody who can tell me what is the problem?

BTW: what does the sambol ?? means?

thanks.........
Questionis there any particular format to convert date selected from asp.net and store it into sql Pin
Learning IT29-Aug-08 22:48
Learning IT29-Aug-08 22:48 
AnswerRe: is there any particular format to convert date selected from asp.net and store it into sql Pin
Christian Graus30-Aug-08 14:48
protectorChristian Graus30-Aug-08 14:48 
AnswerRe: is there any particular format to convert date selected from asp.net and store it into sql Pin
Abhishek Sur31-Aug-08 9:56
professionalAbhishek Sur31-Aug-08 9:56 
GeneralRe: is there any particular format to convert date selected from asp.net and store it into sql Pin
Christian Graus31-Aug-08 13:01
protectorChristian Graus31-Aug-08 13:01 
QuestionHow my client tool will run over internet Pin
koolprasad200329-Aug-08 22:37
professionalkoolprasad200329-Aug-08 22:37 
AnswerRe: How my client tool will run over internet Pin
Christian Graus30-Aug-08 14:49
protectorChristian Graus30-Aug-08 14:49 
Questioncheckbox list changed? Pin
Member 387988129-Aug-08 21:33
Member 387988129-Aug-08 21:33 
AnswerRe: checkbox list changed? Pin
Learning IT29-Aug-08 21:57
Learning IT29-Aug-08 21:57 
AnswerRe: checkbox list changed? Pin
Manas Bhardwaj29-Aug-08 22:17
professionalManas Bhardwaj29-Aug-08 22:17 
QuestionAutoCompleteType = "Disabled" not working in firefox Pin
ashok@techxygen29-Aug-08 21:27
ashok@techxygen29-Aug-08 21:27 
Questiongibberish controls Pin
helelark12329-Aug-08 21:02
helelark12329-Aug-08 21:02 
AnswerRe: gibberish controls Pin
Mujahid Ullah Shaik31-Aug-08 8:37
Mujahid Ullah Shaik31-Aug-08 8:37 
Questionvs2008 masterpage Pin
ncsubbu29-Aug-08 20:46
professionalncsubbu29-Aug-08 20:46 
AnswerRe: vs2008 masterpage Pin
Ashfield30-Aug-08 8:24
Ashfield30-Aug-08 8:24 
QuestionDifference betwen server.transfer and response.redirect Pin
BalasubramanianK29-Aug-08 20:34
BalasubramanianK29-Aug-08 20:34 
AnswerRe: Difference betwen server.transfer and response.redirect Pin
Manas Bhardwaj29-Aug-08 20:38
professionalManas Bhardwaj29-Aug-08 20:38 
GeneralRe: Difference betwen server.transfer and response.redirect Pin
BalasubramanianK29-Aug-08 20:51
BalasubramanianK29-Aug-08 20:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.