我有这样的网格视图:
<asp:SqlDataSource ID="SqlPersistentOffenders" runat="server"></asp:SqlDataSource>
<asp:GridView ID="GVPersistentOffenders" runat="server" DataSourceID="SqlPersistentOffenders" AllowPaging="true" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="PersonID" Visible="false">
<ItemTemplate>
<asp:Label ID="LabCreUser" runat="server" Text='<%# Bind("creUser")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="ButtonSendEmail" runat="server" CommandName="SendEmail" CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>" Text="Send Email" OnClientClick="GetEmailAddress()"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)
JavaScript看起来像这样:
<script type="text/javascript">
function GetEmailAddress(creuser) {
//Do something
}
</script>
Run Code Online (Sandbox Code Playgroud)
如何将LabCreUser中的值传递给选择的行到Javasript函数?
我看过这里:在onclientclick中将变量传递给javascript以及其他一些问题.我没有尝试过任何工作.
我正在努力理解 IEnumerable 的好处。我知道 Enumerables 允许延迟执行。
请参阅此处的示例:https : //msdn.microsoft.com/en-us/library/system.collections.ienumerable(v=vs.110).aspx。在此示例中,该数组已填充到主类中,然后注入到 IEnumerable 类中。因此,这似乎消除了推迟执行的优势。我在这里缺少什么?
请看下面的代码:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE Test
AS
BEGIN
begin
select * into #dbreviews from dbreviews
end
drop table #dbreviews
begin
select * into #dbreviews from dbreviews
end
END
GO
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
'#dbreviews'数据库中已经有一个命名的对象。
像这样的问题:数据库中已经有一个名为“#columntable”的对象告诉我这应该是可能的。
请看下面的人员类:
public class Person
{
int _id { get; set; }
string _name { get; set; }
public Person (int id, string name)
{
_id = id;
_name = name;
}
public Person()
{
}
public IEnumerable<Person> GetPeople()
{
_id = 1;
_name = "James";
yield return this;
_id = 2;
_name = "Michael";
yield return this;
_id = 3;
_name = "Sarah";
yield return this;
}
}
Run Code Online (Sandbox Code Playgroud)
以及下面的客户代码:
Person p1 = new Person();
IEnumerable<Person> personEnumerable = p1.GetPeople();
List<Person> personList …Run Code Online (Sandbox Code Playgroud) 请参阅下面的代码,这是我的单元测试的一部分:
mockPersonFactory.Setup(m => m.Create()).Returns(PersonFactory());
public IPerson PersonFactory()
{
IPerson iPerson = new Person();
return iPerson;
}
Run Code Online (Sandbox Code Playgroud)
PersonFactory应该多次调用(因为它包含在被测试代码的循环中).但是,不是Person每次在循环中创建新的,而是每次都重用同一个人对象.如何确保在每个循环上创建新Person?
请看下面的代码:
@model NHibernate.AspNet.Identity.IdentityRole
@{
ViewBag.Title = "Edit";
Layout = "~/Areas/Administration/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Id)
<div>
Role name
</div>
<p>
@Html.TextBoxFor(model => model.Name)
</p>
<input type="submit" value="Save" />
}
Run Code Online (Sandbox Code Playgroud)
和下面的代码:
[HttpPost]
public ActionResult Edit(IdentityRole role)
{
Service.Update(role);
TempData["Comment"] = "The record was updated";
return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)
Role.Id 在控制器中始终为空。Role.Description 包含正确的值。
角色不会更新,因为 Role.Id 为空。问题是什么?
我正在尝试使用Nspec。我已按照以下说明进行操作:http : //nspec.org/
using NSpec;
using FluentAssertions;
class my_first_spec : nspec
{
string name;
void before_each()
{
name = "NSpec";
}
void it_asserts_at_the_method_level()
{
name.ShouldBeEquivalentTo("NSpec");
}
void describe_nesting()
{
before = () => name += " Add Some Other Stuff";
it["asserts in a method"] = () =>
{
name.ShouldBeEquivalentTo("NSpec Add Some Other Stuff");
};
context["more nesting"] = () =>
{
before = () => name += ", And Even More";
it["also asserts in a lambda"] …Run Code Online (Sandbox Code Playgroud) 在谈论六角形架构时,我试图理解端口和适配器的含义。今晚我读了很多解释,但是我还没有找到代码示例。因此我将设计一个。我将端口理解为一个接口。例如:
public interface IPerson
{
string GetName();
}
Run Code Online (Sandbox Code Playgroud)
适配器是实现接口的类:
public class Person : IPerson
{
//Implementation of GetName here
}
Run Code Online (Sandbox Code Playgroud)
我理解四联适配器模式的概念。但是,我不明白这如何适合 DDD。
在 DDD 上下文中查看一个简单的代码示例确实对我有帮助。
我最近在家中的电脑上卸载了 Visual Studio 2017 Community 版并安装了 Visual Studio 2019 Community 版。
由于此处描述的问题,我从未设法使硬件加速工作:https://superuser.com/questions/1482586/cannot-launch-an-x86-android-emulator-using-hyperv-but-can-with- haxm-为什么
但是,使用 Visual Studio 2017,我可以在“开始”菜单中使用“Visual Studio Emulator for Android”,如下所示:
我将启动其中一个模拟器,它将出现在 Visual Studio 2017 中进行调试,如下所示:
但是,在“适用于 Android 的 Visual Studio 模拟器”中启动后,Visual Studio 2019 不会在 Visual Studio 中显示模拟器。我需要配置什么才能使其正常工作吗?
visual-studio xamarin.android xamarin xamarin.forms visual-studio-emulator
我创建了一个应用程序,它使用 Docker 创建容器。该应用程序第一次构建大约需要 20-30 分钟,此后构建速度非常快。
在我的 MAC 上;容器会一直保留到我删除它们为止。但是,在我的 Windows PC 上;每次关闭 Visual Studio 2017 时都会自动删除容器。因此,每次我在 Windows PC 上打开全新的解决方案时,我都必须坐下来等待解决方案的构建。
每次在我的 Windows PC 上关闭 Visual Studio 时,有没有办法阻止 Docker 删除容器?
到目前为止,我已经在 Docker 桌面和 Visual Studio/Options 中寻找了一个设置,但是我找不到它。我也谷歌了这个。
c# ×7
ienumerable ×2
.net ×1
asp.net ×1
asp.net-mvc ×1
docker ×1
ienumerator ×1
javascript ×1
macos ×1
moq ×1
nhibernate ×1
nspec ×1
nunit ×1
sql ×1
sql-server ×1
t-sql ×1
unit-testing ×1
vb.net ×1
windows ×1
xamarin ×1