Gridview中的TemplateField问题 [英] Problem with TemplateField in Gridview
本文介绍了Gridview中的TemplateField问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在网格视图中添加了模板字段。
我想显示的只是第一行。我不想在剩下的行中显示它。
请帮助
解决方案
< pre lang =xml> < asp:GridView ID = GVSE runat = server EmptyDataText = 未找到记录 样式 = margin-bottom:6px
< span class =code-attribute> BorderColor = #BDBDBD CssClass = center DataKeyNames = farmername,batchno AutoGenerateColumns = false
OnRowUpdating = GVSE_RowUpdating OnRowCancelingEdit = GVSE_RowCancelingEdit OnRowEditing = < span class =code-keyword> GVSE_RowEditing >
< 列 >
< asp:TemplateField HeaderText = S.No。 FooterStyle -HorizontalAlign = 中心 ItemStyle-HorizontalAlign = 中心 >
< ItemTemplate >
<% #Container。 DataItemIndex + 1 %>
< / ItemTemplate >
< / asp:TemplateField >
< asp:TemplateField HeaderText = 短缺 >
< ItemTemplate > ;
< asp:标签 ID = lbl_shortage runat = server 文本 =' <% #DataBinder.Eval(Container.DataItem, 短缺)%> ' > < / asp:标签 >
< / ItemTemplate >
I have added template field in my grid view.
I want to display is for the fist row only. I don't want to show it for the rest of rows.
Please help
解决方案
<asp:GridView ID="GVSE" runat="server" EmptyDataText="No Records Found" Style="margin-bottom: 6px" BorderColor="#BDBDBD" CssClass="center" DataKeyNames="farmername,batchno" AutoGenerateColumns="false" OnRowUpdating="GVSE_RowUpdating" OnRowCancelingEdit="GVSE_RowCancelingEdit" OnRowEditing="GVSE_RowEditing"> <Columns> <asp:TemplateField HeaderText="S.No." FooterStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <%# Container.DataItemIndex + 1 %> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Shortage"> <ItemTemplate> <asp:Label ID="lbl_shortage" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"shortage") %>'></asp:Label> </ItemTemplate>
这篇关于Gridview中的TemplateField问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文