错误属性'itemtemplate'没有名为'commandname'的属性 [英] Error property 'itemtemplate' does not have a property named 'commandname'
本文介绍了错误属性'itemtemplate'没有名为'commandname'的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试添加comandname但它不起作用
我再问一遍前一个问题未答复
我有什么试过:
< asp:TemplateField HeaderText =' < img width =20pxheight =20pxsrc = ../Images/updown.png\"/>Id' ItemStyle-HorizontalAlign = 中心 >
< itemtemplate commandname = 排序 commandargument = < span class =code-keyword> myDBfield > <% #Container .DataItemIndex + 1 %> < / itemtemplate >
< asp:BoundField HtmlEncode = false DataField = LoanType HeaderText =' < img src =../ Images / updown.png/> LoanType' SortExpression = LoanType / >
< asp:BoundField DataField = LoanTerm HeaderText = Term(Years) SortExpression = LoanTerm / >
< asp:BoundField DataField = LoanRate HeaderText = LoanRate < span class =code-attribute> SortExpression = LoanRate / > ;
< asp:BoundField DataField = LoanAvailableFrom HeaderText = 贷款可用于 SortExpression = LoanAvailableFrom / >
< asp:BoundField DataField = LoanAvailableTo Hea derText = 贷款可用于 SortExpression = LoanAvailableTo / >
< span class =code-keyword>< asp:CommandField HeaderText = 编辑 SelectText = 编辑 ShowSelectButton = < span class =code-keyword> True / >
< asp:CommandField HeaderText = 删除 ShowDeleteButton = True ShowHeader = True / >
解决方案
错误信息非常明显 -ItemTemplate
aTemplateField
字段 [ ^ ]不包含名为<$ c的属性$ c> CommandName 或CommandArgument
。它只是一个占位符,可以显示在该列中的任何内容。
如果您希望列中的值可以点击,那么您需要添加一个按钮
或LinkButton
到模板:
< asp:TemplateField ... >
< span class =code-keyword>< ItemTemplate >
< asp:按钮 runat = server
< span class =code-attribute> CommandName = 排序
< span class =code-attribute> CommandArgument = myDBfield
文字 =' <% #Container.DataItemIndex + 1 < span class =code-pagedirective>%> '
< span class =code-attribute> / >
< / ItemTemplate >
< / asp:TemplateField >
如果您希望列可以排序,那么设置SortExpression
属性TemplateField
:
< <温泉n class =code-leadattribute> asp:TemplateField ... SortExpression = myDBfield >
< ItemTemplate >
<% #Container.DataItemIndex + 1 %>
< / ItemTemplate >
< / asp:TemplateField > < /跨度>
I tried adding comandname but it does not work
I am asking again as previous question unanswered
What I have tried:
<asp:TemplateField HeaderText='<img width="20px" height="20px" src="../Images/updown.png"/>Id' ItemStyle-HorizontalAlign="Center" >
<itemtemplate commandname="Sort" commandargument="myDBfield"><%#Container.DataItemIndex+1%></itemtemplate>
<asp:BoundField HtmlEncode="false" DataField="LoanType" HeaderText='<img src="../Images/updown.png"/>LoanType' SortExpression="LoanType" />
<asp:BoundField DataField="LoanTerm" HeaderText="Term(Years)" SortExpression="LoanTerm" />
<asp:BoundField DataField="LoanRate" HeaderText="LoanRate" SortExpression="LoanRate" />
<asp:BoundField DataField="LoanAvailableFrom" HeaderText="Loan Available From" SortExpression="LoanAvailableFrom" />
<asp:BoundField DataField="LoanAvailableTo" HeaderText="Loan Available To" SortExpression="LoanAvailableTo" />
<asp:CommandField HeaderText="Edit" SelectText="Edit" ShowSelectButton="True" />
<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ShowHeader="True" />
解决方案
The error message is pretty self-explanatory - theItemTemplate
for aTemplateField
field[^] doesn't contain properties calledCommandName
orCommandArgument
. It's just a placeholder for whatever you want to appear in that column.
If you want the values in the column to be clickable, then you'll need to add aButton
orLinkButton
to the template:
<asp:TemplateField ...> <ItemTemplate> <asp:Button runat="server" CommandName="Sort" CommandArgument="myDBfield" Text='<%# Container.DataItemIndex + 1 %>' /> </ItemTemplate> </asp:TemplateField>
If you want the column to be sortable, then set theSortExpression
property on theTemplateField
:
<asp:TemplateField ... SortExpression="myDBfield"> <ItemTemplate> <%# Container.DataItemIndex + 1 %> </ItemTemplate> </asp:TemplateField>
这篇关于错误属性'itemtemplate'没有名为'commandname'的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文