We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

cant set cellvalue when its an Int16

Hi, I'm trying to set an Int16 cellvalue with the following: ((GTHub.Form1)this.sf).gridHierDataBoundGrid1.Model[((GTHub.Form1)this.sf).gridHierDataBoundGrid1.CurrentCell.RowIndex, ((GTHub.Form1)this.sf).gridHierDataBoundGrid1.CurrentCell.ColIndex].CellValue = System.Convert.ToInt16(this.Model[a.RowIndex, 1].Text); Its a drop down grid and i'm setting the parent grid value on a mouse click... It works on the first row but all other give me the following exception: "Format exception: input string was not in a correct format ... Expected type is Int16" I've tried alot of variations, even changed the celltype to textbox which didn't work either, probably because the bound field is Int16. If I store it to another column which is string type then it works fine... So what do i need to do for these Int16's TIA Colin

6 Replies

AD Administrator Syncfusion Team November 14, 2003 03:29 PM UTC

If you use WriteLine to display this.Model[a.RowIndex, 1].Text right before you try the code you listed above, what value gets displayed in the output?

CL Colin Lamarre November 14, 2003 03:42 PM UTC

It is the expected value. Just noticed that the first row works but only if it's the first thing I do. If I click around it fails like the others.

AD Administrator Syncfusion Team November 14, 2003 04:11 PM UTC

You might also check the value of grid[row, col].CellValueType to see what the grid is expecting. If it is not Int16, then you might try explicitly setting the GridBoundColumn.StyleInfo.CellValueType to typeof(int16). Can you post a sample here (or through Direct Trac) showing the problem?

CL Colin Lamarre November 14, 2003 06:01 PM UTC

Very good! I had a gbcc["truckno"].StyleInfo.CellType = "DBDropDownGridCell" but not a gbcc["truckno"].StyleInfo.CellValueType = typeof(Int16) so thanks for pointing me in the right direction. So now I'm putting the value in like in the first post and all is well after the move to the model (can see that in the debugger) but somehow it gets set to dbnull in the end a shows a blank. why's it doing that? Thanks alot!

CL Colin Lamarre November 14, 2003 06:22 PM UTC

Wow! added a ((GTHub.Form1)this.sf).gridHierDataBoundGrid1.Binder.EndEdit() between the beginupdate and endupdate and now it works almost fine, just that you have to click another cell for it to display... guess i'll look into that now but if you have a quick answer then by all means.

CL Colin Lamarre November 14, 2003 06:40 PM UTC

Ok added a ((GTHub.Form1)this.sf).gridHierDataBoundGrid1.CurrentCell.CancelEdit() and its fine. thanks for the help!

Live Chat Icon For mobile
Up arrow icon