我有一个ASP.Net MVC应用程序,其中包含一个包含集合的多层深度模型.
我相信创建对象的视图都是正确设置的,但是当我将表单发布到服务器时,它只是不填充模型中的集合.
我有一个数据,可以在类层次结构中找到:
person.PersonDetails.ContactInformation[0].Data;
Run Code Online (Sandbox Code Playgroud)
此类结构由LinqToSQL创建,ContactInformation是类型EntitySet<ContactData>.要创建视图,我传递以下内容:
return View(person);
Run Code Online (Sandbox Code Playgroud)
在视图中我有一个表单,其中包含一个文本框,其名称与上述字段相关联:
<%= Html.TextBox("person.PersonDetails.ContactInformation[0].Data")%>
Run Code Online (Sandbox Code Playgroud)
我的控制器中的post方法如下:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create (Person person)
{
//Do stuff to validate and add to the database
}
Run Code Online (Sandbox Code Playgroud)
正是在这一点上我迷失了人.PersonDetails.ContactInformation.Count()== 0.因此,ModelBinder创建了一个ContactInformation对象,但没有填充它应该在索引0处保存的对象(即ContactData).
我的问题有两个方面:1.我采取了正确的方法......即这应该有效吗?2.关于为什么它可能无法填充ContactInformation对象的任何想法?
非常感谢,理查德
我在我的Web应用程序中有一个ADO.NET Entity-Framework*.edmx文件.
当我在浏览器中浏览(当应用程序运行时)到edmx文件时,它不显示错误页面,就像浏览到*.cs或vb文件一样,它会打开edmx并向所有显示我的模型方案用户!
我怎么能避免这种情况.
我在asp.net proj中有一个类,我想从站点的任何地方访问GetGlobalResourceObject(那个页面公开),可能吗?
换句话说,我想从一个不是我不关心的页面的类中访问全局资源.
我有3个表:Item - 这是DataContext - 它有一个导航列Group Group - 有一个导航列Category.
我希望在DataGrid中包含(类别和组)列,当我选择一个类别时,它应该只在组列中显示Category.Groups.
这是我正在处理的代码:
<tk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding}">
<tk:DataGrid.Columns>
<!--Works-->
<tk:DataGridComboBoxColumn
Header="Categroy"
DisplayMemberPath="Title"
SelectedValuePath="CategoryId"
SelectedValueBinding="{Binding Group.Category.CategoryId}"
ItemsSource="{Binding Context.Categories,
Source={x:Static Application.Current}}"
/>
<!--Look at these two things:-->
<!--This does work-->
<tk:DataGridTemplateColumn>
<tk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ItemsControl
ItemsSource="{Binding Group.Category.Groups}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type data:Group}">
<TextBlock Text="{Binding Title}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</tk:DataGridTemplateColumn.CellTemplate>
</tk:DataGridTemplateColumn>
<!--But this does NOT work, even it's the same source-->
<!--Notice I even tried a dummy converter and doesnt reach there-->
<tk:DataGridComboBoxColumn
Header="Group"
DisplayMemberPath="Title"
SelectedValuePath="GroupId"
ItemsSource="{Binding Group.Category.Groups, …Run Code Online (Sandbox Code Playgroud) 我正在寻找使用c#mvc 3创建主/详细信息的示例代码.
具体来说,我试图弄清楚如何通过ajax调用局部视图的渲染.我可以将部分视图放在表单上,但是想要在用户通过ajax从选择列表中选择项目后填充它.
谢谢
我有一个简单的模型
class User
has_many :logs
class Logs
Run Code Online (Sandbox Code Playgroud)
通过外键logs.user_id以通常的方式相关.我正在尝试使用Arel执行以下操作,并且根据Arel doc它应该可以工作.
u_t = Arel::Table::new :users
l_t = Arel::Table::new :logs
counts = l_t.
group(l_t[:user_id]).
project(
l_t[:user_id].as("user_id"),
l_t[:user_id].count.as("count_all")
)
l_t.joins(counts).on(l_t[:id].eq(counts[:user_id]))
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我得到了错误
TypeError: Cannot visit Arel::SelectManager
Run Code Online (Sandbox Code Playgroud)
然而,Arel的作者明确暗示 Arel可以做这种事情.
请不要写关于如何使用原始sql,另一种类型的Arel查询等实现相同查询的响应.这是我感兴趣的模式,而不是此查询的特定结果.
为什么以下隐含DataTemplate不起作用?只有注释的内联才DataTemplate有效.
注意:如果我删除了两个DataTemplates,我会看到ProductListView完整类型名称的字符串表示.
<Window.Resources>
<DataTemplate DataType="vm:ProductListViewModel">
<v:ProductListView/>
</DataTemplate>
</Window.Resources>
<TabControl ItemsSource="{Binding Tabs}" TabStripPlacement="Left">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key}"/>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<ContentPresenter Content="{Binding Value}">
<!--ContentPresenter.ContentTemplate>
<DataTemplate DataType="vm:ProductListViewModel">
<v:ProductListView/>
</DataTemplate>
</ContentPresenter.ContentTemplate-->
</ContentPresenter>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
Run Code Online (Sandbox Code Playgroud) 多少内存以字节为单位做的类型,如int,bool,float,double,decimal,object,和string当作为场添加到一个类的实例使用?
我正在寻找在.NET中实现服务/客户端通信的命名管道,并且遇到了这样的代码,虽然初始化管道的服务器端必须为管道设置安全描述符.他们这样做了:
PipeSecurity pipeSecurity = new PipeSecurity();
// Allow Everyone read and write access to the pipe.
pipeSecurity.SetAccessRule(new PipeAccessRule("Authenticated Users",
PipeAccessRights.ReadWrite, AccessControlType.Allow));
// Allow the Administrators group full access to the pipe.
pipeSecurity.SetAccessRule(new PipeAccessRule("Administrators",
PipeAccessRights.FullControl, AccessControlType.Allow));
Run Code Online (Sandbox Code Playgroud)
但我看着它,我很担心,指定的SID为字符串,或Authenticated Users和Administrators零件.用中文或其他语言来称呼它们的保证是什么?
我有一些输入字段,我想要样式,最初看起来像标签,然后通过angular.js应用样式,以便按下按钮后可以编辑它们.我正在使用bootstrap,是否有内置类可以切换这些输入?
c# ×3
.net ×2
asp.net ×2
wpf ×2
ajax ×1
angularjs ×1
arel ×1
asp.net-mvc ×1
binding ×1
css ×1
datatemplate ×1
file-access ×1
html ×1
httpcontext ×1
inner-join ×1
memory ×1
resources ×1
security ×1
sid ×1
windows ×1
wpftoolkit ×1