datalist itemcommand 怎么有问题
<asp:DataListrunat="server"ID="dls"DataKeyField="newsId"CellSpacing="8"OnItemCommand=...
<asp:DataList runat="server" ID="dls" DataKeyField="newsId" CellSpacing="8" OnItemCommand="dls_ItemCommand" OnDeleteCommand="dls_DeleteCommand" OnEditCommand="dls_EditCommand" OnSelectedIndexChanged="dls_SelectedIndexChanged" OnUpdateCommand="dls_UpdateCommand" OnCancelCommand="dls_CancelCommand">
<ItemTemplate>
<asp:LinkButton ID="lkbt1" runat="server" CommandName="select" CausesValidation="false" Font-Underline="false" >
<%# DataBinder.Eval(Container.DataItem,"title")%>
</asp:LinkButton>
<asp:Button ID="btnedit" runat ="server" CommandName ="edit" Text ="编辑" CausesValidation="false" />
<asp:Button ID="btndelete" runat="server" Text="删除" CommandName="delete" />
</ItemTemplate>
<EditItemTemplate >
<asp:Label ID="lblnid" runat ="server"><%#DataBinder .Eval (Container .DataItem ,"newsID") %></asp:Label>
<asp:TextBox ID="txttitle" runat ="server" Text ='<%#DataBinder .Eval (Container .DataItem ,"title") %>'></asp:TextBox>
<asp:TextBox ID="txtcontent" runat ="server" Text ='<%#DataBinder .Eval (Container .DataItem ,"contenter") %>'></asp:TextBox>
<asp:Button ID="btnupdate" runat ="server" Text ="更新" CommandName ="update" />
<asp:Button ID="btncancle" runat ="server" Text ="取消" CommandName ="cancel" />
</EditItemTemplate>
</asp:DataList>
CS文件 都没有写错。
就是每次 点 “编辑button” “更新button” “取消button”
都会执行itemtemplate, 就是会通过“title” 索引 去打开网页, 比如 我点“XXXX成功”标题的 编辑button,也会打开 "XXXX成功“的内容,求大神。 展开
<ItemTemplate>
<asp:LinkButton ID="lkbt1" runat="server" CommandName="select" CausesValidation="false" Font-Underline="false" >
<%# DataBinder.Eval(Container.DataItem,"title")%>
</asp:LinkButton>
<asp:Button ID="btnedit" runat ="server" CommandName ="edit" Text ="编辑" CausesValidation="false" />
<asp:Button ID="btndelete" runat="server" Text="删除" CommandName="delete" />
</ItemTemplate>
<EditItemTemplate >
<asp:Label ID="lblnid" runat ="server"><%#DataBinder .Eval (Container .DataItem ,"newsID") %></asp:Label>
<asp:TextBox ID="txttitle" runat ="server" Text ='<%#DataBinder .Eval (Container .DataItem ,"title") %>'></asp:TextBox>
<asp:TextBox ID="txtcontent" runat ="server" Text ='<%#DataBinder .Eval (Container .DataItem ,"contenter") %>'></asp:TextBox>
<asp:Button ID="btnupdate" runat ="server" Text ="更新" CommandName ="update" />
<asp:Button ID="btncancle" runat ="server" Text ="取消" CommandName ="cancel" />
</EditItemTemplate>
</asp:DataList>
CS文件 都没有写错。
就是每次 点 “编辑button” “更新button” “取消button”
都会执行itemtemplate, 就是会通过“title” 索引 去打开网页, 比如 我点“XXXX成功”标题的 编辑button,也会打开 "XXXX成功“的内容,求大神。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询