change a coloumn's data in the data binding source
-
06 Ağustos 2012 Pazartesi 06:45
I have a Win Forms Application developed using VS2008.
The databinding is done by executing a query and then, displaying some data in a data grid.
I need to change a column A inside the grid to start showing Column B in the query result.
I am not sure how to find where and how the binding was done to alter it.
I can find the definition of the grid and the query /table adapter.Select Command to see the query etc.
Please advice how to start displaying the correct value in the grid. How to alter the mapping between the grid and the query result.
Thanks in advance
Tüm Yanıtlar
-
06 Ağustos 2012 Pazartesi 12:39
Hello,
- Click on the datadridview in Design mode
- Click on the small arrow in the upper-right corner of the datagridview
- Click "Edit columns"
- When selecting a column on the left handside, you should see its data in the "Data" section on the right
-
06 Ağustos 2012 Pazartesi 23:34
Thanks for replying.
I have checked the mapping of the datagrid.
It looks like the column is matching with the right column, somehow the value displayed in the grid is some calculated value, not the same value as in the query result.
I need to change the calculation. Please suggest how to find where the calculations are done before displaying the value on the grid.
Thanks in advance
-
07 Ağustos 2012 Salı 05:42Moderatör
Hi Cheerfulwish,
Thanks for you post.
Please share some specific information about your issue, such as the code about your application and the structure of the database.
I also have no idea about what “calculate” means. If you want to display new data, just use SQL query to select new the data and rebind the datagridview with new data.
If I misunderstood, please share more information about your issue.
Mark Liu-lxf [MSFT]
MSDN Community Support | Feedback to us
- Düzenleyen Mark Liu-lxfModerator 07 Ağustos 2012 Salı 05:43
-
07 Ağustos 2012 Salı 23:23
I cannot rebind the data grid view.
The binding and queries were created with the wizard initially.
Meanwhile i have been making changes to the queries inside the datadesign.xsd files.
Now if I use the wizard again to configure the databinding,I loose all the changes in the queries done by me.
I cannot take that approach.
In the query result I can see the value of Price as correct price, but when it is displayed in the grid view the price is multiplied by weight of each item.
So I want to display the original price as given by the query result not the multiplied value. I cannot find where is the calculation happening.
-
08 Ağustos 2012 Çarşamba 09:12Moderatör
Hi Cheerfulwish
>>In the query result I can see the value of Price as correct price, but when it is displayed in the grid view the price is multiplied by weight of each item.
>>So I want to display the original price as given by the query result not the multiplied value. I cannot find where is the calculation happening.
Would you like to share the structure of database and the query ? If you use wizard to show the data into datagridview, the data in datagridview will be the same with the datatable witch is bound with datagridview. So you need to check the data in the datatable firstly.
Personally, if you want to show some customer result of the database query, I will suggest you to use code instead of wizard to deal with the issue.
Hope this helps.
Mark Liu-lxf [MSFT]
MSDN Community Support | Feedback to us
-
14 Ağustos 2012 Salı 23:23
I have checked the value in the datatable, it is the wrong price, that is what is displayed in the grid.
I am not showing the query as it is too big and will not make sense to you.
i have checked the Query by going into the .xsd file, that has auto generated code. I believe that file is formed when we create a SQL Query by Wizard for data binding.
The Query if I run on the SQL I can see the correct price. -
16 Ağustos 2012 Perşembe 07:17Moderatör
Hi Cheerfulwish,
It is strange. So you mean that the Query in the .xsd file is the same with the one you tested on the SQL database, but they the different results?
The Query in .xsd can be edited. So how about the result just copying the Query in your SQL database to the Commandtext property of .xsd file? Also you can click the button on the right to open the Query Builder to test the Query. Here is a screenshot:
Hope this helps.
Mark Liu-lxf [MSFT]
MSDN Community Support | Feedback to us
- Yanıt Olarak İşaretleyen Mark Liu-lxfModerator 22 Ağustos 2012 Çarşamba 06:00
-
22 Ağustos 2012 Çarşamba 06:00Moderatör
Hi Cheerfulwish,
We haven’t heard from you for several days. I’d like to mark my reply as answer firstly. If you have any additional questions, you also can unmark the replay and post your question here.
Sorry for any inconvenience and have a nice day.
Mark Liu-lxf [MSFT]
MSDN Community Support | Feedback to us