我有一个绑定到业务对象列表的DataGridView:
Dim template As New IncidentTemplate
Dim temps As List(Of IncidentTemplate) = template.LoadAll
Dim bs As New BindingSource
If Not temps Is Nothing Then
bs.DataSource = temps
Me.dgvTemplates.DataSource = bs
End If
Run Code Online (Sandbox Code Playgroud)
然后我添加一个未绑定的按钮列,并使一些绑定列不可见:
Dim BtnCol As New DataGridViewButtonColumn
With BtnCol
.Name = "Edit"
.Text = "Edit"
.HeaderText = String.Empty
.ToolTipText = "Edit this Template"
.UseColumnTextForButtonValue = True
End With
.Columns.Add(BtnCol)
BtnCol = Nothing
For Each col As DataGridViewColumn In Me.dgvTemplates.Columns
Select Case col.Name
Case "Name"
col.DisplayIndex = 0
col.FillWeight = …Run Code Online (Sandbox Code Playgroud) 我正在尝试匹配一个SEDOL(正好是7个字符:6个字母数字字符后跟1个数字字符)
我的正则表达式
([A-Z0-9]{6})[0-9]{1}
匹配正确,但是以有效匹配开头的大于7个字符的字符串也匹配(如果你看到我的意思:)).例如:
B3KMJP4
匹配正确,但也是如此:
B3KMJP4x
哪个不应该匹配.
谁能告诉我如何避免这种情况?
给定格式为字符串的字符串:XXX999999v99(其中X是任何字母字符,v是任何数字字符,v是文字v字符)如何获得正则表达式以匹配v后面的数字字符?到目前为止,我有'v\d\d',其中包括v,但理想情况下我只想要数字部分.
另外,有人知道一个工具,你可以在其中指定一个匹配的字符串并生成正则表达式吗?修改现有的正则表达式是一回事,但我发现从头开始痛苦!
编辑:重新阅读这个问题我意识到它看起来像一个家庭作业!但是我可以向你保证,不是,我想要匹配的字符串代表产品代码附加的产品版本.当前代码使用各种子字符串表达式来检索版本部分.
我正在使用Rob Conery的Massive进行数据库访问.我想围绕几个插入包装事务,但第二个插入使用从第一个插入返回的标识.对我来说,在交易中如何做到这一点并不明显.一些援助将不胜感激.
var commandList = new List<DbCommand>
{
contactTbl.CreateInsertCommand(new
{
newContact.Name,
newContact.Contact,
newContact.Phone,
newContact.ForceChargeThreshold,
newContact.MeterReadingMethodId,
LastModifiedBy = userId,
LastModifiedDate = modifiedDate,
}),
branchContactTbl.CreateInsertCommand(new
{
newContact.BranchId,
ContactId = ????, <-- how to set Id as identity from previous command
}),
};
Run Code Online (Sandbox Code Playgroud) 有没有一种在.Net中动态构建文件路径的简单方法?目前我正在通过连接各种字符串(来自应用程序设置,用户输入和Date.ToString)来构建文件路径,但这依赖于字符串中没有双重'\'字符或非法字符等.显然我可以手动验证这类字符串的字符串,但我想知道是否有内置的.Net可以处理这个问题.
我正在使用DataTable.Select过滤日期范围内的数据表,我的条件字符串是:
"CreatedOn >='03/11/2009 00:00:00' AND CreatedOn <='03/11/2009 23:59:00'"
Run Code Online (Sandbox Code Playgroud)
此过滤器不返回任何行(即使我可以在未过滤的数据表中看到匹配的行).但是我注意到我将标准更改为(注意日/月换位):
"CreatedOn >='11/03/2009 00:00:00' AND CreatedOn <='11/03/2009 23:59:00'"
Run Code Online (Sandbox Code Playgroud)
数据表按预期过滤.显然这似乎是一个日期本地化问题,是否有一种简单的方法来格式化日期以避免这个问题?
我试图调用一个接受表值参数的存储过程。
我正在遵循有关此问题的指南,实现自定义参数类型:
internal class IntDynamicParam
{
string name;
IEnumerable<int> numbers;
public IntDynamicParam(string name,IEnumerable<int> numbers)
{
this.name = name;
this.numbers = numbers;
}
public void AddParameters(IDbCommand command)
{
var sqlCommand = (SqlCommand)command;
sqlCommand.CommandType = CommandType.StoredProcedure;
List<Microsoft.SqlServer.Server.SqlDataRecord> number_list = new List<Microsoft.SqlServer.Server.SqlDataRecord>();
// Create an SqlMetaData object that describes our table type.
Microsoft.SqlServer.Server.SqlMetaData[] tvp_definition = { new Microsoft.SqlServer.Server.SqlMetaData("n", SqlDbType.Int) };
foreach (int n in numbers)
{
// Create a new record, using the metadata array above.
Microsoft.SqlServer.Server.SqlDataRecord rec = new Microsoft.SqlServer.Server.SqlDataRecord(tvp_definition); …Run Code Online (Sandbox Code Playgroud) 我有一个事件处理程序,用于在Plupload中引发错误时:
Error: function(up, args) {
// do something
}
Run Code Online (Sandbox Code Playgroud)
如何在代码中的其他位置引发错误?我想说up.RaiseError("something is wrong etc").
我使用ServiceStack构建了一个简单的Rest服务(很棒),它返回一个键值对列表.
我的服务如下:
public class ServiceListAll : RestServiceBase<ListAllResponse>
{
public override object OnGet(ListAllResponse request)
{
APIClient c = VenueServiceHelper.CheckAndGetClient(request.APIKey, VenueServiceHelper.Methods.ListDestinations);
if (c == null)
{
return null;
}
else
{
if ((RequestContext.AbsoluteUri.Contains("counties")))
{
return General.GetListOfCounties();
}
else if ((RequestContext.AbsoluteUri.Contains("destinations")))
{
return General.GetListOfDestinations();
}
else
{
return null;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的回答如下:
public class ListAllResponse
{
public string County { get; set; }
public string Destination { get; set; }
public string APIKey { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我已经映射了其余的URL,如下所示: …
.net ×6
c# ×3
regex ×2
vb.net ×2
dapper ×1
datagridview ×1
datatable ×1
massive ×1
orm ×1
plupload ×1
servicestack ×1
sql ×1
web-services ×1