Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
How to solve this error...
help
cannot convert from 'System.Web.UI.WebControls.GridView to 'System.Windows.Forms.DataGridView
Posted 29-Nov-12 0:55am
sahmed4562
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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...
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
 
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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

gridview is a web control but DataGridView is a windows application control.so u can't convert web control into windows control.....
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 553
1 George Jonsson 258
2 OriginalGriff 235
3 CPallini 210
4 PIEBALDconsult 155
0 OriginalGriff 5,865
1 Sergey Alexandrovich Kryukov 5,316
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100