[英]Is it possible to edit a GridView cell without an edititemtemplate?
[英]Is it possible to scroll in a cell of a gridview?
我的gridview中有一些記錄。 但是每個記錄都存在問題,有一個單元格包含大量數據。 我仍然想顯示數據並允許用戶向下滾動閱讀(如果他們感興趣)。 是否有可能允許在該單元格中滾動?
編輯:
這是我提到的css:
.AspNet-GridView
{
overflow: auto;
height:400px;
}
.AspNet-GridView table thead tr th
{
height:20px;
position:relative;
}
.AspNet-GridView table tbody
{
overflow: auto;
}
編輯2:這是gridview,我想要帶有headertext主體的列允許滾動。
<asp:GridView ID="gvAanvragen"
OnPageIndexChanging="GvAanvragen_PageIndexChanging" runat="server" AllowPaging="True"
AllowSorting="True" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical"
PageSize="5" AutoGenerateColumns="false" AutoGenerateSelectButton="True"
onselectedindexchanged="GvAanvragen_SelectedIndexChanged"
CssClass="AspNet-GridView">
<RowStyle BackColor="#F7F7DE" />
<FooterStyle BackColor="#CCCC99" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField HeaderText="ID" DataField="ID" />
<asp:BoundField HeaderText="Subject" DataField="Subject" />
<asp:BoundField HeaderText="Body" DataField="Body" HtmlEncode="false" />
<asp:BoundField HeaderText="Sent" DataField="Sent" />
</Columns>
</asp:GridView>
有人能幫助我嗎?
您可以使用模板列並在其中放置一個div,其中style="overflow:auto;"
<asp:TemplateField>
<ItemTemplate>
<div style="overflow:auto; height: 100px;"><Your Content here></div>
</ItemTemplate>
</asp:TemplateField>
為了增加Naveed的答案,現在您已經發布了原始代碼: http : //www.asp.net/data-access/tutorials/using-templatefields-in-the-gridview-control-cs有一個很好的例子數據綁定模板字段:
<asp:TemplateField HeaderText="FirstName" SortExpression="FirstName">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
在您的情況下,只需更換線
<asp:BoundField HeaderText="Body" DataField="Body" HtmlEncode="false" />
通過Naveed提供的代碼,並在此示例中添加數據綁定,並最終得到如下內容:
<asp:TemplateField HeaderText="Body">
<ItemTemplate>
<div style="overflow:auto; height: 100px;">
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Body")%>'></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
如果您不想使用標簽,請改用文字控件:
<asp:Literal ID="Literal1" runat="server" Text='<%# Bind("Body")%>' />
您可以添加模板列,並在該列內部將所有內容放入帶有溢出設置的div中(請參閱CSS溢出)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.