-
May 20th, 2013, 10:10 PM
#1
DataGridView Does Not Accept Values in All Columns
Would like to ask what are the possible causes for columns of cells in a datagridview not to show values being pushed into it?
I have a datagridview with about 40+ columns and for some strange reason a number of columns are able to accept values I am pushing into them using:
datagridview.rows[rowindexhere].cells[columnindexhere].value = valueToPushHere;
whereas a number of others wont accept it? This is really weird and not sure if there are some undocumented things or limitations about Datagridview control that new users like me need to be aware of to ensure successful push of info into the control 100% of the time?
Thanks so much for all the help you could give ... I really appreciate it.
Gratefully,
Matt
-
May 20th, 2013, 10:52 PM
#2
Re: DataGridView Does Not Accept Values in All Columns
It could be that the data you think you are putting in there is blank.
Check to make sure you can insert test data into all 40 columns for one row.
-
May 21st, 2013, 09:36 AM
#3
Re: DataGridView Does Not Accept Values in All Columns
Thanks I tried what you suggested, I changed the values as described below with result also indicated:
Change 1: I changed all the values pushed to the 48 columns to be the string
"Writing here"
Result : About six columns responded and reflected the change
Change 2: I then proceeded to change the value from "Writing here" to the number 68
Result : 30+ columns have responded and reflected the new value 68
This is good and indicates that the type of data pushed have an influence on whether the value actually gets to land in the grid or not.
Unfortunately, the particular column whose cells I am interested in altering remains unaffected so there seems something odd about it ...
All the columns get populated on the fly via a stored procedure that is mapped to a dataadapter that is created inside a .xsd file.
The one odd thing about the particular column I want to affect via code is that it is not actually a column existing in a table instead it is created via with a little t-sql manipulation in the select statement of the stored procedure alongside the other normal columns similar to the one shown
Select NormalColumnActuallyExisting1,
NormalColumnActuallyExisting2,
NormalColumnActuallyExisting3,
ColumnCreatedOnFly = Case When NormalColumnActuallyExisting1 = 1 then ...
When NormalColumnActuallyExisting2 = 1 then ...
When NormalColumnActuallyExisting3 = 1 then ...
Else ...
End
NormalColumnActuallyExisting3,
...
The odd (ColumnCreatedOnFly) gets populated with a hardcoded string based on the bit values of NormalColumnActuallyExisting1, NormalColumnActuallyExisting2 and NormalColumnActuallyExisting3 columns so it really puzzles me why it wont accept the string in the Change 1 I have described above...
So I did the changes below:
Change 3: I then proceeded to change the value from 68 to the boolean true
Result : The odd column whose value I want to change still remains unaffected
Change 4: I then proceeded to change the value from true to the integer 0 (for bit)
Result : The odd column whose value I want to change still remains unaffected
All I want is to be able to push a string in that said odd column but finding the grid not cooperating with me right now ... so wondering is there a way for me
to make it happen ... thanks again for all the help I really appreciate it.
-
May 21st, 2013, 02:04 PM
#4
Re: DataGridView Does Not Accept Values in All Columns
No code so... no indication whether you are using Datasource or not. If using Datasource you have to remember that what is showing is not your data but a hidden copy of your data created when you set Datasource=something. If you change your copy of the data, then you have to reset Datasource so it can make a hidden copy of the new data to display.
-
May 22nd, 2013, 08:00 PM
#5
Re: DataGridView Does Not Accept Values in All Columns
Thanks for all the help ... I really appreciate it ..
After about an hour trying out different values and observing the same weird behaviour, I tried converting to ordinary normal columns (i.e introducing an actual column to the table as opposed to working with ColumnCreatedOnFly column above)
The result was a resounding success showing that it might be somekind of limitation in the DataGridView control which prohibits use of on the fly created virtual (non-existing) column ...
For now this works for me and maybe as I learn more of DataGridView I will discover more what can and can't be done with it. ... thanks again
-- case solved --
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|