编辑,删除这些按扭不自带的,如果不是管理员就不应该显示编辑,删除这些按扭。这应该怎么做?
解决方案 »
- 怎么验证数据库里的信息
- 帮忙看一下这个软件功能是用什么控件实现的??
- 是否任意数据类型都可以转换成二进制块存入SQLServer的image类型中
- C#语言:将EXCEL表格中的数据复制到dataTable中,然后用dt.rows.count统计的数据条数与EXCEL中的实际数据条数不符。
- 如何出现启动图标。
- DataGrid数据更新问题!在线等!如秋枫在一定帮我看看!急
- datagrid编辑列不能为空的问题?
- 哪位大哥能给我详细解释一下怎么在WEB下实现3及权限呀 小弟是菜鸟 第一次做这个 请多指教 50分一定给
- 关于事件捕捉问题?!
- 问题两则,在线等待!
- 求助:用C#把text中的内容写入到txt中再读取?
- 如何实现水晶报表中的bool值的CheckBox的显示?
Width="100%" CssClass="Grid_Item" DataKeyNames="FeelingsID" OnRowDataBound="gvw_RowDataBound" AllowPaging="True" AllowSorting="True" >
<Columns>
<asp:BoundField HeaderText="报道标题" DataField="FeelingsTitle" >
<itemstyle horizontalalign="Left" Width="250px" />
<headerstyle horizontalalign="Center" width="250px" />
</asp:BoundField>
<asp:BoundField HeaderText="报道媒体" DataField="Media" >
<itemstyle horizontalalign="Center" />
<headerstyle horizontalalign="Center" width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText="发表日期" DataField="FeelingsPublishDate" >
<itemstyle horizontalalign="Center" />
<headerstyle horizontalalign="Center" width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText="关键词" DataField="KeyWords" >
<itemstyle horizontalalign="Center" Width="80px" />
<headerstyle horizontalalign="Center" width="80px" />
</asp:BoundField>
<asp:BoundField HeaderText="工作属性" DataField="WrokAttribute" >
<itemstyle horizontalalign="Center" Width="50px" />
<headerstyle horizontalalign="Center" width="50px" />
</asp:BoundField>
<asp:BoundField HeaderText="事件地点" DataField="Country" >
<itemstyle horizontalalign="Center" Width="130px" />
<headerstyle horizontalalign="Center" width="130px" />
</asp:BoundField>
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:ImageButton ImageUrl = "../App_Themes/Images/edit.gif" ID="iBtnEdit" runat="server" OnClick="iBtnEdit_Click"/>
<asp:ImageButton ImageUrl = "../App_Themes/Images/bt_icon_del.gif" ID="iBtnDelete" runat ="server" OnClick="iBtnDelete_Click" />
<asp:ImageButton ImageUrl = "../App_Themes/Images/bt_icon_search.gif" ID="iBtnView" runat ="server" OnClick="iBtnView_Click" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="100px" />
<HeaderStyle HorizontalAlign="Center" Width="100px" />
</asp:TemplateField>
</Columns>
<AlternatingRowStyle CssClass="altertr" />
<RowStyle CssClass="Grid_Item" />
<PagerSettings Visible="False" />
</asp:GridView>你在GridView的gvw_RowDataBound事件中,这样写ImageButton imageBtnDelete = e.Row.Cells[6].FindControl("iBtnDelete") as ImageButton;
imageBtnDelete.Visible = false;
就行了。
示例如下:<asp:GridView ...>
<Columns>
....
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" CommandName="Delete" CommandArgument='<%# Eval("ArticleID") %>' Visible='<%# ArticleRule.CanDelete(Container.DataItem) %>' Text="删除" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView
<Columns>
<asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />
</Columns>如果在程序里能得到ShowDeleteButton属性,那么就可以将他设为false这样就不显示了,我想知道如何得到这个属性???
先找到button,用findcontrol
然后用声明得button得id 比如 bn 直接做判断,登陆类型就好了如果是管理员 bn.visiable=true
否则 bn.visiable=false