Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ASP.NET中自动调整GridView行中文本框的大小_Asp.net - Fatal编程技术网

如何在ASP.NET中自动调整GridView行中文本框的大小

如何在ASP.NET中自动调整GridView行中文本框的大小,asp.net,Asp.net,我正在尝试在GridView行中添加数据绑定文本框: <ItemTemplate > <asp:TextBox ID="TextBox" runat="server" Visible="true" Enabled="true" Wrap="true" text='<%#Eval("Notes")%>' TextMode="MultiLine" > </asp:TextBox>

我正在尝试在GridView行中添加数据绑定文本框:

<ItemTemplate >
<asp:TextBox ID="TextBox" runat="server" Visible="true" Enabled="true" 
                 Wrap="true" text='<%#Eval("Notes")%>' TextMode="MultiLine" >
    </asp:TextBox>                  
</ItemTemplate>

我不知道如何使文本框自动调整为GridView行的高度

如果您想知道多行文本框中内容的高度,您可以根据文本框的字体大小使用一个简单的公式。 在此处输入代码,例如数字不真实。 如果一行80个字符的宽度为400px,高度为20px,那么一行160个字符的宽度始终为400px,但高度为40px。 因此,在文本框的高度属性中,您可以编写

高度=


您也可以通过java脚本来完成

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Automatic Resize TextBox</title>
<script type="text/javascript">
function setHeight(txtdesc) {
txtdesc.style.height = txtdesc.scrollHeight + "px";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtDesc" runat= "server" TextMode="MultiLine"  onkeyup="setHeight(this);" onkeydown="setHeight(this);" />
</form>
</body>
</html>

谢谢很好!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Automatic Resize TextBox</title>
<script type="text/javascript">
function setHeight(txtdesc) {
txtdesc.style.height = txtdesc.scrollHeight + "px";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtDesc" runat= "server" TextMode="MultiLine"  onkeyup="setHeight(this);" onkeydown="setHeight(this);" />
</form>
</body>
</html>