I am currently filling a dataTable then adding this table to a dataset, setting the dataset to the Gridview's datasource.
If I set the Gridview to generate columns automatically it will fill the grid just fine, but I can't get the automated column (column index 1) to be set to readonly. (Column 0 is actually an automated column of edit buttons)
here's my code:
notice I do set Column[0] to readonly, but this isn't readonly when binded to the grid, as my edit feature allows for the editing of that column.
Is this an issue with my edit handler/functionality?
Now if I set manual columns in the Gridview, this dataset will not fill those columns when binded to the gridview. Will only bind if I have automated columns set.
ETA: this is an ASP.Net app.
thanks.
If I set the Gridview to generate columns automatically it will fill the grid just fine, but I can't get the automated column (column index 1) to be set to readonly. (Column 0 is actually an automated column of edit buttons)
here's my code:
Code:
DataSet ds = new DataSet();
DataTable dt = new DataTable();
ds.Tables.Add(dt);
DataColumn dc = new DataColumn("search #");
dc.ReadOnly = true;
dt.Columns.Add(dc);
dc = new DataColumn("1");
dt.Columns.Add(dc);
dc = new DataColumn("2");
dt.Columns.Add(dc);
dc = new DataColumn("3");
dt.Columns.Add(dc);
dc = new DataColumn("4");
dt.Columns.Add(dc);
DataRow dr;
object[] myArray = new object[maxElements];
for (int a = 0; a < numSearches; a++)
{
for (int b = 0; b < maxElements; b++)
{
myArray[b] = array[a, b];
}
dr = dt.NewRow();
dr.ItemArray = myArray;
dt.Rows.Add(dr);
}
GridView2.DataSource = ds;
GridView2.DataBind();
Is this an issue with my edit handler/functionality?
Now if I set manual columns in the Gridview, this dataset will not fill those columns when binded to the gridview. Will only bind if I have automated columns set.
ETA: this is an ASP.Net app.
thanks.
Comment