问题描述
- 求助:如何实现Asp.net的GridView里Linkbutton的enable=false???
-
我在Asp.net前台页面Source里面添加了一个GridView,里面嵌套了一个Linkbutton.前台代码如下:<asp:GridView ID="GridView2" runat="server" AllowPaging="True" OnPageIndexChanging="gvOrderList2_PageIndexChanging" EnableModelValidation="false" Height="308px" Style="margin-top: 0px" Width="544px" DataKeyNames="OrderID" AutoGenerateColumns="False" AllowSorting="True" PageSize="12" BackColor="#FFCC99" BorderColor="#FFCC00" OnRowDataBound="GridView2_RowDataBound" OnDataBound="GridView2_OnDataBound"> <Columns> <asp:BoundField HeaderText="序号" ReadOnly="True"> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="OrderID" HeaderText="订单号" ReadOnly="True"> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="OrderDate" HeaderText="订单日期" ReadOnly="True"> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="GoodsName" HeaderText="商品名称" ReadOnly="True"> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="HotPrice" HeaderText="单价(¥)" ReadOnly="True"> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="Num" HeaderText="数量" ReadOnly="True"> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="ShipFee" HeaderText="运费(¥)" ReadOnly="True"> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="TotalPrice" HeaderText="总价(¥)" ReadOnly="True"> <ItemStyle HorizontalAlign="Center" /> <HeaderStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:TemplateField> <HeaderStyle HorizontalAlign=Center /> <ItemStyle HorizontalAlign =Center /> <ItemTemplate > <asp:LinkButton ID="lnkbtnGoPay" runat="server" OnClick="lnkbtnGoPay_OnClick" CommandArgument='<%#Eval("OrderID") %>' OnCommand="lnkbtnGoPay_Command">去付款</asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
运行效果如下图(这幅图是订单类型为“未付款”时效果):
问题:在后台代码中:
当订单类型为“已付款”时,我如何实现将GridView最后一列的“去付款”属性Enable=false???
恳请各位行家高手不吝惜指教!万分感谢!!
解决方案
用jquery改变css样式,定义一个伪类,字体颜色灰色、下划线去掉。
以及href="#"
解决方案二:
后台判断,如果已付款就设置其控件属性为 Enable=false
解决方案三:
如果已付款可以在后台将控件值改为“已付款”
控件名.text="已付款";
控件名.Enable=false;
望采纳,谢谢
时间: 2024-12-28 17:00:02