[英]Read only for column in gridview
I had Gridview bind sqldatasource and I had logins which see gridview and I made roles for these logins som of them cannot see all gridview column so how can I make some columns read only .? 我有Gridview绑定sqldatasource,我有登录看到gridview,我为这些登录创建了角色,他们无法看到所有gridview列,所以我怎样才能让一些列只读。
code public void CheckLoginAuthorty() { code public void CheckLoginAuthorty(){
using (SqlConnection Con = Connection.GetConnection())
{
SqlCommand com = new SqlCommand("CheackLoginInRole", Con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add(Parameter.NewNVarChar("@Login", Session.Contents["Username"].ToString()));
object O = com.ExecuteScalar();
if (O != null)
{
string S = O.ToString();
if (IsInRole("AR-Translator", O.ToString()))
{
///////// Grideview code/////////////////
}
else if (IsInRole("EN-Translator", O.ToString()))
{
/////////Grideview code/////////////////
}
}
}
}
EDIT: 编辑:
All you need to do is set the ReadOnly
property to true
您需要做的就是将
ReadOnly
属性设置为true
eg 例如
WinForms DataGridView WinForms DataGridView
dataGridView1.Columns["ColumnName"].ReadOnly = true;
WebForms GridView WebForms GridView
((BoundField)gridView1.Columns[columnIndex]).ReadOnly = true;
DataGridViewColumn column;
column.ReadOnly = true;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.