I want to hide ID column in my GridView, I knew the code
GridView1.Columns[0].Visible = false;
but the surprise was that my count property for my GridView
columns is 0 !!! while I can see data in the GridView
, so any ideas?
Thank you,
Update:
here is the complete code for the method which populate the GridView
public DataSet GetAllPatients()
{
SqlConnection connection = new SqlConnection(this.ConnectionString);
String sql = "SELECT [ID],[Name],[Age],[Phone],[MedicalHistory],[Medication],[Diagnoses] FROM [dbo].[AwadyClinc_PatientTbl]order by ID desc";
SqlCommand command = new SqlCommand(sql, connection);
SqlDataAdapter da = new SqlDataAdapter(command);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
question from:https://stackoverflow.com/questions/3819247/gridview-hide-column-by-code