我正在构建一个页面,将LINQ查询结果显示为表格.
我收到了错误
无法将lambda表达式转换为类型'string',因为它不是委托类型
在代码行
this.articles = from art in this.articles
where art.category_id == this.categoryId
select art;
Run Code Online (Sandbox Code Playgroud)
任何想法如何修复下面的代码?
namespace WebApplication3 {
public partial class _Default : System.Web.UI.Page {
private IQueryable articles;
protected void Page_Load(object sender, EventArgs e) {
this.SetupArticleQuery();
this.UpdateFilter();
}
private void SetupArticleQuery() {
this.articles = from a in KB.Articles
join t in KB.Teams on a.primary_team_id equals t.id
join cat in KB.Categories on a.category_id equals cat.id
join scat in KB.SubCategories on a.subcategory_id equals scat.id
join top in KB.Topics …Run Code Online (Sandbox Code Playgroud) 我想定义一个接受SET中字符串的变量,然后将其转换为Int32并在GET期间使用它.
这是我目前拥有的代码:
private Int32 _currentPage;
public String currentPage
{
get { return _currentPage; }
set
{
_currentPage = (string.IsNullOrEmpty(value)) ? 1 : Convert.ToInt32(value);
}
}
Run Code Online (Sandbox Code Playgroud) 我的页面上有一个转发器:
<asp:Repeater id="attachmentsRepeater" runat="server">
<HeaderTemplate>
<%
if (attachmentsRepeater.Items.Count > 0) {
if (attachmentsRepeater.Items.Count == 1) {
Response.Write("<h3>Attachment</h3>");
Response.Write("<p>");
} else {
Response.Write("<h3>Attachments</h3>");
Response.Write("<ul>");
}
}
%>
</HeaderTemplate>
<ItemTemplate>
<%# OutputAttachment(Container)%>
</ItemTemplate>
<FooterTemplate>
<%
if (attachmentsRepeater.Items.Count > 0) {
if (attachmentsRepeater.Items.Count == 1) {
Response.Write("</p>");
} else {
Response.Write("</ul>");
}
}
%>
</FooterTemplate>
</asp:Repeater>
Run Code Online (Sandbox Code Playgroud)
原始的ItemTemplate代码如下所示:
<ItemTemplate>
<%
if (attachmentsRepeater.Items.Count > 0) {
if (attachmentsRepeater.Items.Count > 1) {
Response.Write("<li>");
}
%>
<a href="<%# DataBinder.Eval(Container.DataItem, "location") %>">
<%# DataBinder.Eval(Container.DataItem, "name") %>
</a>
<% …Run Code Online (Sandbox Code Playgroud)