none
Casting dataGridView.DataSource to DataView

    Question

  • i want to Cast dataGridView1.DataSource to DataView

    i try to this way  DataView dataView = (DataView)dataGridView1.DataSource;

    but get the error to Unable to cast object of type 'System.Data.DataTable' to type 'System.Data.DataView'.

    is possible, please help.


    rageshS
    Friday, September 30, 2011 7:18 AM

Answers

  • Hi,

    Just try this and let me know if it works

     

    DataTable sam =(DataTable ) dataGridView1.DataSource;

     

    DataView dt1 = new DataView(sam);

    If not working , let me know whether your datsource is a binding datasource?

    Regards,

    A.Murugan


    If it solved your problem,Please click "Mark As Answer" on that post and "Mark as Helpful". Happy Programming!
    • Marked as answer by RageshShiva Friday, September 30, 2011 8:34 AM
    Friday, September 30, 2011 7:43 AM

All replies

  • Hi,

    Just try this and let me know if it works

     

    DataTable sam =(DataTable ) dataGridView1.DataSource;

     

    DataView dt1 = new DataView(sam);

    If not working , let me know whether your datsource is a binding datasource?

    Regards,

    A.Murugan


    If it solved your problem,Please click "Mark As Answer" on that post and "Mark as Helpful". Happy Programming!
    • Marked as answer by RageshShiva Friday, September 30, 2011 8:34 AM
    Friday, September 30, 2011 7:43 AM
  • it's work fine.

    Thanks for your valuable replay.


    rageshS
    Friday, September 30, 2011 8:34 AM