I need some help about to hide 1 or more Gridview Columns in asp.net.
What i am trying to do, is that i want to hide a GridView Column deepending on the type of the user (Administrator or Standart).
I tryed this code:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection Conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["KlientiStrConn"].ConnectionString);
Conn1.Open();
string SqlQry1 = "select TipiPedoruesi from Perdoruesi where Emri = '" + TxtBox1.text + "'";
SqlCommand SqlCmd1 = new SqlCommand(SqlQry1, Conn1);
string y = SqlCmd1.ExecuteScalar().ToString();
Conn1.Close();
if (y == "Administrator")
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowtype.Header);
{
e.Row.Cells[1].Visible = true;
}
}
else if(y == "Standart")
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowtype.Header);
{
e.Row.Cells[1].Visible = false;
}
}
}
But it shows to me a lot of errors.
I have made a print screen of the errors.
Thank you in advance...!!!

New Topic/Question
Reply



MultiQuote




|