Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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 January 6th, 2010, 09:32 AM
Authorized User
 
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
Question Filter Columns

Can I have some help with this C#code

the problem is with "valueToUseAsAFilter" could advise what to use instead
Code:
bindingSource1.Filter = string.Format("MycolumnName = '{0}'", valueToUseAsAFilter);
            DataView Dv = new DataView(new_HomeDataSet.NHE, "EMPLOYEE_NAME", "column you will use to sort data", DataViewRowState.CurrentRows);
 
Old January 6th, 2010, 09:37 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

DO you get a specific exception? If so, telling what the actual 'problem' is would help rather than making us guess.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 6th, 2010, 09:42 AM
Authorized User
 
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
Default Filter Column

Hi thank you for having a look
yes I get this error

Error 1 The name 'valueToUseAsAFilter' does not exist in the current context
 
Old January 6th, 2010, 09:45 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

So you don't have a variable called valueToUseAsAFilter? Well where are you storing the value you want to filter on?
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 6th, 2010, 10:03 AM
Authorized User
 
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
Default Filter Column

As i do not have varable i have changes valueToUseAsAFilter
to where the data source is = new_HomeDataSet
This is all my code hope you can help?
Code:
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.tableAdapterManager1.Fill(this.new_HomeDataSet.NHE);
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbConnection dr;
            
            bindingSource1.Filter = string.Format("MycolumnName = '{0}'", new_HomeDataSet);
            DataView Dv = new DataView(new_HomeDataSet.NHE, "EMPLOYEE_NAME", "column you will use to sort data", DataViewRowState.CurrentRows);

System.NotImplementedException = System.NotImplementedException
The method or operation is not implemented.
 
Old January 6th, 2010, 10:29 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

No, that makes no sense. Which line are you getting the exception on? new_HomeDataSet is a DataSet object correct? How is passing that into String.Format going to produce a sensible value?

This code looks so bad I don't know where to start. Do you have a column in your data called 'MycolumnName'? What about the string "column you wioll use to sort data" = shouldn't that have been replaced by an actual column name?

Have you cut and paste this code from some web site? If so I suggest you go back to the web site and try and actually understand what the code is doing before trying to change it to work with your data.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
headworth (January 6th, 2010)
 
Old January 7th, 2010, 02:20 AM
robinsonsmith
Guest
 
Posts: n/a
Default

It wouldn't if you are working in filtered mode. You need to have all data displayed and then use filter again.
Where to Buy Lean Muscle X
Lean Muscle X
Received Infraction
The Following User Says Thank You to For This Useful Post:
headworth (January 7th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide Columns, Filter & Copy Visable to new wrkbk dursta Excel VBA 1 June 4th, 2007 06:17 AM
Filter Help mcloum Classic ASP Databases 2 November 10th, 2005 05:40 PM
Filter Help mcloum BOOK: Beginning ASP 3.0 1 August 26th, 2005 03:10 PM
How to filter data? coolest_pie SQL Server 2000 7 May 7th, 2004 07:00 PM
sum'ing columns after a filter (in rs) nlicata SQL Server ASP 2 August 21st, 2003 03:52 AM





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