Hi
I am getting error on below line - grdPlanning.Columns["SessionDate"].ReadOnly = false;
grdPlanning.DataSource = dt;
grdPlanning.Columns["SessionDate"].ReadOnly = false;
grdPlanning.DataBind();
Thanks
Hi
I am getting error on below line - grdPlanning.Columns["SessionDate"].ReadOnly = false;
grdPlanning.DataSource = dt;
grdPlanning.Columns["SessionDate"].ReadOnly = false;
grdPlanning.DataBind();
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Brahma Prakash ShuklaRank #633 · 3.8K reputationPosted May 5, 2023, 8:41 AM EDT
The error you are encountering may be related to the fact that the "SessionDate" column does not exist in the grid or the data source.
To troubleshoot this issue, you can try the following:
Make sure that the "SessionDate" column exists in the data source (the DataTable "dt" in this case) and that it is spelled correctly.
Check if the "SessionDate" column is added to the grid before setting its ReadOnly property. You can do this by checking the Columns collection of the grid.
If the column exists, check if its ReadOnly property is set to true before trying to change it to false. Setting the ReadOnly property of a read-only column will raise an error.
If the above steps do not help, please provide more details about the error message you are receiving so that I can help you better.
Jignesh KumarRank #91 · 22.9K reputationPosted May 5, 2023, 8:46 AM EDT
Hello,
As Brahma prakash shukla indeicate that your gridview does not have "sessionDate" Column, I think in your previous post you have datatable with "Date" Name, please try below
grdPlanning.DataSource = dt; ((BoundField)grdPlanning.Columns[1]).ReadOnly = false; grdPlanning.DataBind();Ramco RamcoRank #462 · 5.4K reputationPosted May 5, 2023, 9:01 AM EDT
Hi Jignesh
I have below code.
When i write below code it gives error - Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
grdPlanning.DataSource = dt;
((BoundField)grdPlanning.Columns[dt.Columns.Count - 1]).ReadOnly = false;
grdPlanning.DataBind();
DataColumn Remarks = new DataColumn("Remarks", typeof(string)); dt.Columns.Add(Remarks); DataColumn Dates = new DataColumn("SessionDate", typeof(string)); dt.Columns.Add(Dates);Thanks