Hello and thanks for looking - I've searched for this and cant get it !
I am trying to set the height of a text box which is in an ItemTemplate in a gridview. The gridview is bound from a datatable in the code behind. I am trying to be able to set the height of the textbox to prevent scrolling. The width is set (30% of container). the Gridview sits in an Updatepanel.
The text contains a mixture of text and carriage returns.
I can do this via javascript but this seems to require setting from e.g. onkeyup
function textAreaAdjust(o) {
o.style.height = o.scrollHeight;
}
but i cant get this to happen on rowdatabound so when the text is placed in the textbox, it is constrained by the height of the height of the gridview row.
here is the code for the itemtemplate
<asp:TemplateField HeaderText="Jobs / Notes" HeaderStyle-CssClass="JobNotesCol">
<EditItemTemplate>
<asp:TextBox ID="JobNotesTB" runat="server" Text='<%# Bind("JobNotes") %>' OnTextChanged="TB_TextChanged" TextMode="MultiLine" style="min-height:98%; width:98%;" onkeyup="textAreaAdjust(this)" AutoPostBack="True" ></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:TextBox ID="JobNotesTB" runat="server" Text='<%# Bind("JobNotes") %>' OnTextChanged="TB_TextChanged" TextMode="MultiLine" style="min-height:98%; width:98%;" onkeyup="textAreaAdjust(this)" AutoPostBack="True" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
So my question is how should i do this - can i work out the height it needs to be and just set this from the c# onrowdatabound ?, or can i fire the java when the row is bound ?
I am restrained by having to use IE8 and so the handy looking jquery autosizing textbox is out ! - until we move into 19th century that is !
thanks for any advice !