我有一个gridview绑定到viewstate,viewstate拥有一个数据表。在gridview中,我有EditItemTemplates。
当我点击完成按钮时,modalpopup显示,
protected void Button1_Click(object sender, System.EventArgs e)
{
mdlPopup.Show();
}
protected void btnCancel_Click(object sender, EventArgs e)
{
mdlPopup.Hide();
}
每当发生回发时,gridview文本框中的数据会以附加的逗号重复。
我有Javascripts:
<script type="text/javascript">
//http://www.codingfusion.com/Post/Max-length-for-multiline-textbox-in-asp-net
function Check(textBox, maxLength) {
if (textBox.value.length > maxLength) {
alert("You cannot enter more than " + maxLength + " characters.");
textBox.value = textBox.value.substr(0, maxLength);
}
}
</script>
<script type="text/javascript">
document.onkeydown = Esc;
function Esc() {
var KeyID = event.keyCode;
if (KeyID == 27) {
if ($find("mdlPopup")) {
$find("mdlPopup").hide();
}
}
}
</script>
Gridview转换为HTML代码:
public override void VerifyRenderingInServerForm(Control control)
{
/* Confirms that an HtmlForm control is rendered for the specified ASP.NET
server control at run time. */
return;
}
private string getHTML(GridView gv)
{
StringBuilder sb = new StringBuilder();
StringWriter textwriter = new StringWriter(sb);
HtmlTextWriter htmlwriter = new HtmlTextWriter(textwriter);
gv.RenderControl(htmlwriter);
htmlwriter.Flush();
textwriter.Flush();
htmlwriter.Dispose();
textwriter.Dispose();
return sb.ToString();
}
我不知道逗号附加到文本框中文本的位置。
任何人都可以帮我这么做吗? 提前谢谢。