我如何处理我不能将代码块放在皮肤文件中的事实?

时间:2022-11-22 21:33:09

I have a asp.net page I'm writing and I'm perplexed by this problem. I have 3 DetailViews that I bind with LINQ. The binding works great. Now, I have a Skin file that I want to use to layout the DVs, and it looks like this.

我有一个我正在写的asp.net页面,我对这个问题感到困惑。我有3个与LINQ绑定的DetailViews。绑定效果很好。现在,我有一个Skin文件,我想用它来布局DV,它看起来像这样。

<asp:DetailsView SkinID="blogViews" runat="server" Width="100%" CssClass="post" 
AutoGenerateRows="False" GridLines="None" FooterStyle-CssClass="comments" FooterStyle-Height="50px">
<Fields>
    <asp:BoundField DataField="blog_title" ShowHeader="False" ItemStyle-CssClass="title" ItemStyle-Font-Size="X-Large"/>
    <asp:BoundField DataField="blog_content" HtmlEncode="False" ShowHeader="False" ItemStyle-CssClass="entry" />
</Fields>

Now the problem is, I need to add a templateField to display some data, and I need it between the title and content fields. By using a template field, I need to do an:

现在的问题是,我需要添加一个templateField来显示一些数据,我需要在标题和内容字段之间。通过使用模板字段,我需要做一个:

Eval("blog_datetime")

and a few others. Unfortunately, the Skin file doesn't allow code blocks. I can't add the template field to the aspx page itself, because it puts the templateField at the bottom of the DetailsView. I guess what I am asking is:

和其他一些人。不幸的是,Skin文件不允许代码块。我无法将模板字段添加到aspx页面本身,因为它将templateField放在DetailsView的底部。我想我要问的是:

How can I work around the fact that I can't put a code block in a skin file?

我如何处理我不能将代码块放在皮肤文件中的事实?

1 个解决方案

#1


I am wondering if you would be better off creating a custom control for laying out these details views?

我想知道你是否最好创建一个自定义控件来布局这些细节视图?

Skin files are for modifying styles more than behavior and binding.

外观文件用于修改样式而不是行为和绑定。

A custom control would allow you to do all of this and get the benefit of shared layout for the three data views.

自定义控件允许您执行所有这些操作,并获得三个数据视图的共享布局的好处。

#1


I am wondering if you would be better off creating a custom control for laying out these details views?

我想知道你是否最好创建一个自定义控件来布局这些细节视图?

Skin files are for modifying styles more than behavior and binding.

外观文件用于修改样式而不是行为和绑定。

A custom control would allow you to do all of this and get the benefit of shared layout for the three data views.

自定义控件允许您执行所有这些操作,并获得三个数据视图的共享布局的好处。