Wrox Programmer Forums
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 9th, 2003, 01:55 AM
Registered User
 
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataView

Hi,

I try to sort on DataView but got an error:
error CS0122: 'System.Data.DataView.sort' is inaccessible due to its protection level

Here is my code:
DataView prodView = prodTable.DefaultView;
prodView.sort = "ProductID";
DataGridDEProduct.DataSource=prodView;
DataGridDEProduct.DataBind();

Can anyone help?

Thanks.
Vivi

 
Old November 9th, 2003, 02:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

have u set Table of Datview?!

Always:),
Hovik Melkomian.
 
Old November 9th, 2003, 07:32 PM
Registered User
 
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Melvik,

Yes I did.
But I still got the error:
error CS0122: 'System.Data.DataView.sort' is inaccessible due to its protection level

Here is my whole code for that section:
public void BindDataGrid()
{
    LabelMessage.Visible = false;
    MyConn = new SqlConnection (conString);
    String sqlSelect = "select ProductID, ProductDescr, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued, Picture, PictureType from TblProduct";
    SqlDataAdapter cmdSelect = new SqlDataAdapter (sqlSelect, MyConn);

    //Create a dataset and fill it with the data
    DataSet ds = new DataSet();
    cmdSelect.Fill(ds, "DEProduct");

    DataTable prodTable = ds.Tables["DEProduct"];

    if (InsertFlag)
    {
        InsertFlag = false;
        DataRow row = prodTable.NewRow();
        prodTable.Rows.Add(row);
    }

        DataView prodView = prodTable.DefaultView;
    prodView.sort = "ProductID";
    DataGridDEProduct.DataSource=prodView;
    DataGridDEProduct.DataBind() ;

}

Can you see anything wrong?

Thanks.
Vivi


 
Old November 9th, 2003, 07:47 PM
Registered User
 
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Melvik,

I got it now.

I should put a capital S for 'Sort' instead of small s.

Thanks.
Vivi

 
Old November 10th, 2003, 01:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

:D Since u know C# is a case sensitive as its a C-Base lang.
so be aware of that!! Really dont u use Visual Stedio.NET!?!
if use that it'll be most easy to go...

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
about how to use dataview to search, thanks! raybristol ASP.NET 1.0 and 1.1 Basics 5 April 25th, 2008 06:02 AM
dataview Yasho VB.NET 2002/2003 Basics 1 May 28th, 2007 03:40 AM
Help with DataReader/Dataview? saf ASP.NET 2.0 Basics 4 December 14th, 2006 01:01 PM
Sorting With dataView anubhav.kumar ADO.NET 1 March 17th, 2005 05:06 AM
DataView Not Sorting pbyrum C# 3 December 27th, 2004 06:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.