dcl120748
asked on
How do I make a single cell in a DataTable ReadOnly?
I am creating a DataTable from a DataReader and conditionally I can make a column ReadOnly as below. However how can I make just a cell in that row ReadOnly rather than the whole column?
while (rdr.Read())
{
DataRow dr = dt.NewRow();
if (rdr.GetDateTime(8).ToStri ng().Equal s("01/01/1 900 00:00:00"))
{
dr[8] = false;
}
else
{
dr[8] = true;
dt.Columns[8].ReadOnly = true;
}
dt.Rows.Add(dr);
}
Thanks,
Dee
while (rdr.Read())
{
DataRow dr = dt.NewRow();
if (rdr.GetDateTime(8).ToStri
{
dr[8] = false;
}
else
{
dr[8] = true;
dt.Columns[8].ReadOnly = true;
}
dt.Rows.Add(dr);
}
Thanks,
Dee
ASKER
Thanks for that Masteraco and perhaps I am misunderstanding but wouldn't that make the whole column ReadOnly and not just the cell? What I need is for the cell contained on that particular row at column 8 to be ReadOnly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Got it. Many thanks.
myDataColumn = DataTable.Columns(8)
myDataColumn.Readonly= true
Hope this helps