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

Output Only Columns in a datagrid

I have a grid of student names and addresses. To eliminate redundant city/state information, I have a lookup function that attempts to post city/state data in a grid (but not back to the datasource) on all new or updated zips. The data is posted from a view where I join zip and student table. The insert/update statements post directly to the tables. The moment I attempt to plug city and state into the grid, I get an error that citystate is read only. I do not want to save the information - just display it. If I post citystate to any other field I have no problem. The datagrid column is set to read. The problem must be that the dataset identifies the citystate as derived. Is there a solution? I am sure it is simple. Thanks!

3 Replies

AD Administrator Syncfusion Team July 15, 2005 03:13 PM UTC

I am not sure I understand what you are doing. Do you want to display data in the GridDataBoundGrid that is not in the DataSource of the grid? If so, you can add an unbound column (or columns), and then use grid.Model.QueryCellInfo to provdie the valuesyou want to so in this unbound column. Here is a sample that has unbound columns in it. \Syncfusion\Essential Studio\3.2.1.0\Windows\Grid.Windows\Samples\DataBound\GDBGMultiHeader


TA Tom Affholter July 15, 2005 04:03 PM UTC

Thanks for the quick response. Let me try to explain. First I am not exactly sure of what you are asking. I use a griddatabound grid. My datasource, as I will describe is a view. I have two tables - tblStudents and tblZipCodes. To avoid redundancy, I do not have the user input a city, state,- rather I perform a lookup and post city/state. I created a view from the joined tables I called vwStudents. I want to manage student information from a datagrid. The grid opens with all data available to edit (vwStudents) but cityState. If they update a zip or enter a new student, I want to post the new/updated city, state in the citystate column. I have correct update and insert statements into tblStudents. Everything works until I attempt to update the dataset. I get an error that citystate is read only. To make sure the problem was not in the datagrid, I made the citystate column readonly=false. But it works fine if I write the city, state to a field from tblStudent such as address. But no where in my insert or update statements do I include citystate. My generated XML code does identify citystate as read only. I would send you the program but I am piped into the college using an internal SQLServer. I''ll bet I could come up with a downsized Access file if need be. I hope this makes more sense. I need to learn more of your componens so to I can create some new student exercises for this fall. Besides, I can use this once in my office once done. Thanks for your time. Tom >I am not sure I understand what you are doing. > >Do you want to display data in the GridDataBoundGrid that is not in the DataSource of the grid? If so, you can add an unbound column (or columns), and then use grid.Model.QueryCellInfo to provdie the valuesyou want to so in this unbound column. Here is a sample that has unbound columns in it. \Syncfusion\Essential Studio\3.2.1.0\Windows\Grid.Windows\Samples\DataBound\GDBGMultiHeader


AD Administrator Syncfusion Team July 15, 2005 04:21 PM UTC

>>citystate column Is this a column that is not in either of the two tables you have? If so, this is what I mean by an unbound column (a column that does not directly map to a single column in the datatable). >>created a view from the joined tables I called vwStudents. Here, you are referring to a DataView object, correct? After you create it, check the value of vwStudents.AllowEdit. Is it false. If it is false and you cannot set it to true, then I suspect ADO,NET is not going to let you modify the joined table that created this DataView object. If you want to display columns from two different tables, and be able to edit some of teh columns, I would probably suggest either using a virtual GridControl to manage this, or to use a GridDataBoundGrid bound to one of the tables, and then add the values form the other table as unbound columns. With either of these techniques, you should not have a problem trying to update things. You can keep the DataTables separate, and then call dataadapter.Update to update each table independently, not having to rely on an joined table.

Loader.
Up arrow icon