GridView控件启用编辑时怎么样使某些列不可被编辑?
2个回答
2017-11-19 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517177
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
当系统标识为用户自定义的时候修改删除可编辑,否则不可编辑!由于设置权限问题,所有在gridview控件中有一个系统标识的掩藏列:
<Columns>
<asp:TemplateField>
<ItemTemplate>
<input type="checkbox" id="ckvalue" <%#Eval("Function_IsSys").ToString() == "2"? " " :"disabled='disabled'" %> name="ckvalue" value='<%# Eval("Function_ID") %>' /></ItemTemplate>
<HeaderTemplate>
<input type="checkbox" id="ckall" name="ckall" disabled="disabled" onclick="CheckAll(this.checked,'ckvalue')" /></HeaderTemplate>
<ItemStyle HorizontalAlign="Center" Width="5%" />
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField HeaderStyle-CssClass="display" ItemStyle-CssClass="display" DataField="Function_IsSys" />
<asp:TemplateField HeaderText="功能编码">
<ItemTemplate>
<%--<a href="javascript:location.href='UserInfoView.aspx?id=<%# Eval("Function_NO") %>'" title="详细">--%><%# Eval("Function_NO")%></a>
</ItemTemplate>
<HeaderStyle Font-Bold="False" HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField HeaderText="功能名称" DataField="Function_Name">
<HeaderStyle HorizontalAlign="Center" Font-Bold="False" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="系统标识">
<ItemTemplate>
<%# Eval("Function_IsSys").ToString() == "1" ? "系统定义" : "用户自定义"%>
</ItemTemplate>
<HeaderStyle Font-Bold="False" HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField HeaderText="功能描述" DataField="Function_Description">
<HeaderStyle HorizontalAlign="Center" Font-Bold="False" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="操 作">
<ItemTemplate>
<%-- <input type="checkbox" id="ckvalue" <%#Eval("Function_IsSys").ToString() == "2"? " " :"disabled='disabled'" %> name="ckvalue" value='<%# Eval("Function_ID") %>' /></ItemTemplate>--%>
<asp:HyperLink ID="Update" ToolTip="修改" runat="server" NavigateUrl='<%#String.Format("ModulFunctionEdit.aspx?id={0}", Eval("FUNCTION_ID")) %>'><img src="../skins/sky/icon/edt.gif" border="0" />修改 </asp:HyperLink>
<asp:HyperLink ID="View" Enabled="false" ToolTip="详情" runat="server" NavigateUrl='<%#String.Format("ModulFunctionView.aspx?id={0}",Eval("FUNCTION_ID")) %>' ><img src="../skins/sky/icon/layout_content.gif" border="0" />详细 </asp:HyperLink>
<%#Eval("Function_IsSys").ToString() == "2"?
"<asp:HyperLink ID='Delete' Enabled='false' runat='server' ToolTip='删除' NavigateUrl='#' ><span style='cursor:pointer' onclick=DelInfoById(" + Eval("FUNCTION_ID") + ",XC_Web.Frame.SystemManage.ModulFunction,'/Frame/SystemManage/ModulFunction.aspx')><img src='../skins/sky/icon/del.gif' border='0'/>删除</span></span></asp:HyperLink>" :
"<asp:HyperLink ID='Delete' runat='server' NavigateUrl='#' ToolTip='删除' disabled='disabled' ><img src='../skins/sky/icon/del.gif' border='0'/>删除</asp:HyperLink>"
%>
</ItemTemplate>
<HeaderStyle Font-Bold="False" />
<ItemStyle HorizontalAlign="Center" Width="22%" />
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<input type="checkbox" id="ckvalue" <%#Eval("Function_IsSys").ToString() == "2"? " " :"disabled='disabled'" %> name="ckvalue" value='<%# Eval("Function_ID") %>' /></ItemTemplate>
<HeaderTemplate>
<input type="checkbox" id="ckall" name="ckall" disabled="disabled" onclick="CheckAll(this.checked,'ckvalue')" /></HeaderTemplate>
<ItemStyle HorizontalAlign="Center" Width="5%" />
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField HeaderStyle-CssClass="display" ItemStyle-CssClass="display" DataField="Function_IsSys" />
<asp:TemplateField HeaderText="功能编码">
<ItemTemplate>
<%--<a href="javascript:location.href='UserInfoView.aspx?id=<%# Eval("Function_NO") %>'" title="详细">--%><%# Eval("Function_NO")%></a>
</ItemTemplate>
<HeaderStyle Font-Bold="False" HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField HeaderText="功能名称" DataField="Function_Name">
<HeaderStyle HorizontalAlign="Center" Font-Bold="False" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="系统标识">
<ItemTemplate>
<%# Eval("Function_IsSys").ToString() == "1" ? "系统定义" : "用户自定义"%>
</ItemTemplate>
<HeaderStyle Font-Bold="False" HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField HeaderText="功能描述" DataField="Function_Description">
<HeaderStyle HorizontalAlign="Center" Font-Bold="False" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="操 作">
<ItemTemplate>
<%-- <input type="checkbox" id="ckvalue" <%#Eval("Function_IsSys").ToString() == "2"? " " :"disabled='disabled'" %> name="ckvalue" value='<%# Eval("Function_ID") %>' /></ItemTemplate>--%>
<asp:HyperLink ID="Update" ToolTip="修改" runat="server" NavigateUrl='<%#String.Format("ModulFunctionEdit.aspx?id={0}", Eval("FUNCTION_ID")) %>'><img src="../skins/sky/icon/edt.gif" border="0" />修改 </asp:HyperLink>
<asp:HyperLink ID="View" Enabled="false" ToolTip="详情" runat="server" NavigateUrl='<%#String.Format("ModulFunctionView.aspx?id={0}",Eval("FUNCTION_ID")) %>' ><img src="../skins/sky/icon/layout_content.gif" border="0" />详细 </asp:HyperLink>
<%#Eval("Function_IsSys").ToString() == "2"?
"<asp:HyperLink ID='Delete' Enabled='false' runat='server' ToolTip='删除' NavigateUrl='#' ><span style='cursor:pointer' onclick=DelInfoById(" + Eval("FUNCTION_ID") + ",XC_Web.Frame.SystemManage.ModulFunction,'/Frame/SystemManage/ModulFunction.aspx')><img src='../skins/sky/icon/del.gif' border='0'/>删除</span></span></asp:HyperLink>" :
"<asp:HyperLink ID='Delete' runat='server' NavigateUrl='#' ToolTip='删除' disabled='disabled' ><img src='../skins/sky/icon/del.gif' border='0'/>删除</asp:HyperLink>"
%>
</ItemTemplate>
<HeaderStyle Font-Bold="False" />
<ItemStyle HorizontalAlign="Center" Width="22%" />
</asp:TemplateField>
</Columns>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询