我不确定如何使用组合键。
我的类别表有CategoryId (PK,FK),LanguageId (PK,FK),CategoryName
CategoryId | LanguageId | CategoryName
1 | 1 | Car
1 | 2 | Auto
1 | 3 | Automobile
etc.我正在关注this设计
默认操作如下所示
//
// GET: /Category/Edit/5
public ActionResult Edit(int id)
{
return View();
}和ActionLink
<%= Html.ActionLink("Edit", "Edit", new { id= item.CategoryId }) %>我应该使用像这样的东西吗
<%= Html.ActionLink("Edit", "Edit", new { id= (item.CategoryId + "-" + item.LanguageId) }) %>因此,url是
/Category/Edit/5-5
和
//
// GET: /Category/Edit/5-5
public ActionResult Edit(string id)
{
// parse id
return View();
}或者将路由更改为如下所示
/Category/Edit/5/5
还是有更好的方法?
发布于 2010-04-05 07:27:47
嗯,这比我想象的要简单:-)只需在ActionLink的RouteValues中放入两个参数,这样它就会生成一个查询字符串。
<%= Html.ActionLink("Edit", "Edit", new { id= item.CategoryId, lang= item.LanguageId }) %>url将为Category/Edit/1?lang=3
因此,在我的问题中,它更多的是关于路由的。有关this的更多信息
发布于 2010-04-05 04:24:20
Yes, there is a better way.您还可以确定user's language and culture from the request,以确定要使用数据库中的哪条记录。我不会想出一个随机的方案,比如1=英语2=德语。使用standard culture identifiers.
https://stackoverflow.com/questions/2575742
复制相似问题