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 .?
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
e.g.
WinForms DataGridView
dataGridView1.Columns["ColumnName"].ReadOnly = true;
WebForms GridView
((BoundField)gridView1.Columns[columnIndex]).ReadOnly = true;
DataGridViewColumn column;
column.ReadOnly = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With