【发布时间】:2010-01-13 23:04:05
【问题描述】:
我正在使用 C# 在 ASP.NET 中使用网格视图和项目模板文本框。我在一行中输入文本并使用输入的键 再次在第二行输入文本。
更新后我将数据放在一行中(我在一行中使用了 50 个字符长度。)。
例如
我的第一行文字。 这是 1 月 13 日的测试。
第二行代码
你好拉维
更新后我越来越喜欢
这是 1 月 13 日的测试。你好 拉维
这是我当前正在使用的代码。
私有 CommandArg GetUpdateCommentArgs(int rowIndex) { var retVal = 新的 CommandArg { ObjectParamCollection = 新字典() };
var commentTxt = new string[] { };
object val = null;
var cmtTb = GridView1.Rows[rowIndex].FindControl("txtComments") as TextBox;
if (cmtTb != null)
{
cmtTb.Text = cmtTb.Text.Replace("\r\n", " ");
var los = cmtTb.Text.Length;
if (los > 100) cmtTb.Text = cmtTb.Text.Substring(0, 100);
commentTxt = los > 50
? new[] {cmtTb.Text.Substring(0, 50), cmtTb.Text.Substring(50)}
: new[] {cmtTb.Text};
}
var key = GridView1.DataKeys[rowIndex];
if (key != null)
val = key.Value;
if (Page is ClaimBase)
{
var p = Page as ClaimBase;
var ci = p.ClaimantInfoHelper;
if (ci != null)
{
if (val != null)
{
var seq = 0;
if (Int32.TryParse(val.ToString(), out seq))
{
var cmtInput = new CommentUpdateInputEntity
{
ClaimNumber = ci.ClaimNum
, CertificateSequence = ci.ClaimCertSeqNo
, Sequence = seq
, CommentText1 = commentTxt[0]
};
if (commentTxt.Length > 1)
cmtInput.CommentText2 = commentTxt[1];
retVal.ObjectParamCollection.Add("entity", cmtInput);
}
}
}
}
return retVal;
}
【问题讨论】: