Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to solve this error...
help
cannot convert from 'System.Web.UI.WebControls.GridView to 'System.Windows.Forms.DataGridView
Posted

The message is pretty clear: You are trying to assign a value to a variable that is not capable of holding it. In this case, you are trying to load a GridView into a DataGridView - they are very different classes and not related.

Without the relevant code fragment, there isn't a lot more I can do...
 
Share this answer
 
You cannot convert webcontrol to windows form control. To resolve this refer webcontrol in web application and refer windows control in windows application. see the highligted difference of namespaces below.

'System.Web.UI.WebControls.GridView to 'System.Windows.Forms.DataGridView
 
Share this answer
 
Answer is already in your error message...I think your going to assign webControls GridView to windows form DataGridView. Those are very different objects and this kind conversion is cannot be done...
Why don't you try assign Data Source...
If there is a way to load data to your Windows form DataGridView.You can assign it like below
C#
Web.UI.WebControls.GridView gV = new Web.UI.WebControls.GridView();

gV.DataSource= dataTableObject; // data table object


you can assign your System.Windows.Forms.DataGridView data source to this data table object
 
Share this answer
 
gridview is a web control but DataGridView is a windows application control.so u can't convert web control into windows control.....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900