How can I set the textarea of the gridview which has a Datatable:
<asp:GridView ID="gvTemplateFields" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Risk">
<ItemTemplate>
<textarea id="Risk"
cols="20" rows="2"
runat="server"
style="width: 99%">
</textarea>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>No off-site links found.</EmptyDataTemplate>
</asp:GridView>
The data binding:
DataTable templateFields = SWMSField.GetTemplateFields(TemplateId);
gvTemplateFields.DataSource = templateFields;
gvTemplateFields.DataBind();
You can use an ASP.NET server control instead:-
<asp:TemplateField HeaderText="Risk">
<ItemTemplate>
<asp:TextBox id="Risk" TextMode="MultiLine" Columns="20" Rows="2" runat="server"
Text='<%# Eval("RiskColumn")%>' />
</ItemTemplate>
</asp:TemplateField>
Here, RiskColumn
is the column name which holds the data you want to bind in textarea.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.