我有这个错误:匿名类型不能有多个具有相同名称的属性.是否可以使用别名解析,即LINQ中是否存在别名
var device_query = from d in DevicesEntities.device
join dt in DevicesEntities.devicetype on d.DeviceTypeId equals dt.Id
join l in DevicesEntities.location on d.Id equals l.DeviceId
join loc in DevicesEntities.locationname on l.LocationNameId equals loc.Id
where l.DeviceId == d.Id
select new {
d.Id,
d.DeviceTypeId,
d.SerialNumber,
d.FirmwareRev,
d.ProductionDate,
d.ReparationDate,
d.DateOfLastCalibration,
d.DateOfLastCalibrationCheck,
d.CalCertificateFile,
d.Notes,
d.TestReportFile,
d.WarrantyFile,
d.CertificateOfOriginFile,
d.QCPermissionFile,
d.Reserved,
d.ReservedFor,
d.Weight,
d.Price,
d.SoftwareVersion,
dt.Name,
dt.ArticleNumber,
dt.Type,
l.StartDate, //AS LastStartDate,
l.LocationNameId,
loc.Name //in this line I have problem
};
Run Code Online (Sandbox Code Playgroud) 这条线
System.DateTime.Parse("09/12/2009");
Run Code Online (Sandbox Code Playgroud)
将日期(字符串)转换为9/12/2009 12:00:00 AM.我怎样才能在9/12/2009的表格中找到日期.
在解释之后我做了:
DateTime dt = System.DateTime.Parse(Request.Form["datepicker"]);
dt.ToString("dd/mm/yyyy");
/* and this code have time, why???*/
Run Code Online (Sandbox Code Playgroud) public ActionResult ReadXMLDevices(int groupID)
{
var query = from k in XMLEntities.unassigneditems
where k.DevOrAcc == true && k.Group == groupID
select k;
var view_query = from i in query
select new GetFreeDevices
{
MArticleNumber = i.ArticleNumber,
MFirmware = i.Firmware,
MGroup = i.Group,
MName = i.Name,
MSoftware = i.SoftwareVersion,
SA = GetNumberOfDevices(i.ArticleNumber,2),
STH = GetNumberOfDevices(i.ArticleNumber,3),
SASTH = GetNumberOfDevices(i.ArticleNumber,7)
};
return PartialView(view_query);
}
public int GetNumberOfDevices(string artNo,int loc)
{
var num_dev = (from k in XMLEntities.deviceview
where k.Reserved == false && k.Sold …Run Code Online (Sandbox Code Playgroud) 在这行代码中
<% var tmp = int.Parse(ViewData["numOfGroups"].ToString()); %>
Run Code Online (Sandbox Code Playgroud)
我有错误:Object reference not set to an instance of an object.如何正确转换
ViewData["numOfGroups"]到int?
我有静态变量的问题.我的控制器组织的一部分如下:
namespace MyApp.Controllers
{
public class DevicesController : Controller
{
static int some_var = 0;
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SetValue(int temp){
some_var = temp;
return RedirectToAction("DisplayValue");
}
[Authorize]
public ActionResult DisplayValue(){
....
return View(some_object);
}
}
}
Run Code Online (Sandbox Code Playgroud)
当多个用户同时使用此视图时会出现问题.所有用户都使用相同的静态变量并更改其值.怎么解决这个?
我希望能够限制“视图”页面上的表中可以包含的行数(我使用的是 ASP.NET MVC),如果有更多行,则会转到下一页。
视图:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Index</h2>
<script type="text/javascript">
$(document).ready(function() {
$(document).ready(function() {
$("#example").submit(function() {
var id = $("#id").val();
var prezime = $("#prezime").val();
$.post("/jQueryPost/PostingData", { id: id, prezime: prezime }, function(res) {
if (res.redirect) {
window.location.href = res.redirect;
return;
}
}, "json");
return false;
});
});
</script>
<form id="example" method = "post">
Id:<input id="id" type="text" />
Prezime:<input id="prezime" type="text" />
<p>
<input type="submit" value="Post Data" />
</p>
</form>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)
控制器动作:
[HttpPost]
public ActionResult PostingData(int id, string prezime)
{
//some code
return …Run Code Online (Sandbox Code Playgroud) 码:
<% foreach (var item in Model) { %>
<td>
<%= Html.Encode(item.BirthDate) %>
</td>
<% } %>
Run Code Online (Sandbox Code Playgroud)
显示:8/24/2009 12:00:00 AM但我只需要日期(2009年8月24日).可以在控制器动作中不进行任何格式化
我有下面的文字框:
<%= Html.TextBox("idbox", "Enter Text here", (string)ViewBag.idbox)%>
$(document).ready(function () {
$('input#idbox').focus(function () {
var txtval = $('input#idbox').val();
if (txtval == 'Enter Text here') { $(this).val(''); }
});
$('input#idbox').focusout(function () {
var txtval = $('input#idbox').val();
if (txtval == "") { $('input#idbox').val('Enter Text here'); }
});
});
Run Code Online (Sandbox Code Playgroud)
我想在facebook上制作类似于短信textarea的文本框.因此,如果我点击文本框末尾放一些字母,那么值'在这里输入文字'是隐藏但如果我再次单击此框,则新值不会隐藏.这是因为if语句总是将值与'在此处输入文本'进行比较.如何更改此代码以使我能够根据焦点自动显示隐藏文本值?