Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Filter Data

Reply
Thread Tools

Filter Data

 
 
ruca
Guest
Posts: n/a
 
      03-03-2004
Hi gurus,
How can I filter data in my DataSet and then put the result in a DataGrid?
NOTE: I'm reading a txt file into a dataset with 3 columns:

Id, Name, Age

I have this:


code------------------------------------------------------------------------
-----------------------
LerLinha = New StreamReader(LerPath)

dsMrc = New DataSet
dtMrc = New DataTable("Mrc")
dcMrc = New DataColumn("Id",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Name",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Age",
System.Type.GetType("System.String"))

dtMrc.Columns.Add("Id")
dtMrc.Columns.Add("Name")
dtMrc.Columns.Add("Age")

dsMrc.Tables.Add(dtMrc)

Do
txtLine = LerLinha.ReadLine()

drMrc = dtMrc.NewRow()
drMrc("Id") = ProcessId(txtLine) 'FindUser
drMrc("Name") = ProcessName(txtLine)
drMrc("Age") = ProcessAge(txtLine)
dtMrc.Rows.Add(drMrc)

dsMrc.Tables("Mrc").Rows.Add(drMrc)
Loop Until txtLine Is Nothing

Dim strFilter As String

strFilter = "Id=" & FindUser

dsMrc.Tables("Mrc").Select(strFilter)

dgMarcacoes.DataSource = dsMrc

LerLinha.Close()
LerLinha = Nothing
code------------------------------------------------------------------------
-----------------------


What's wrong??????

--

Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca


 
Reply With Quote
 
 
 
 
Martin Dechev
Guest
Posts: n/a
 
      03-03-2004
<snip>
> dsMrc.Tables("Mrc").Select(strFilter)

<snip>
> What's wrong??????


The Select method on the DataTable class returns an array of DataRow objects
that match the filter criteria. You should use the returned array. The call
to Select doesn't modify the DataTable itself.

Greetings
Martin


 
Reply With Quote
 
 
 
 
Felbrigg
Guest
Posts: n/a
 
      03-03-2004
Maybe I'm missing something, but in the posted code, i dont think the
"Finduser" variable is set.

"ruca" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi gurus,
> How can I filter data in my DataSet and then put the result in a DataGrid?
> NOTE: I'm reading a txt file into a dataset with 3 columns:
>
> Id, Name, Age
>
> I have this:
>
>
>

code------------------------------------------------------------------------
> -----------------------
> LerLinha = New StreamReader(LerPath)
>
> dsMrc = New DataSet
> dtMrc = New DataTable("Mrc")
> dcMrc = New DataColumn("Id",
> System.Type.GetType("System.String"))
> dcMrc = New DataColumn("Name",
> System.Type.GetType("System.String"))
> dcMrc = New DataColumn("Age",
> System.Type.GetType("System.String"))
>
> dtMrc.Columns.Add("Id")
> dtMrc.Columns.Add("Name")
> dtMrc.Columns.Add("Age")
>
> dsMrc.Tables.Add(dtMrc)
>
> Do
> txtLine = LerLinha.ReadLine()
>
> drMrc = dtMrc.NewRow()
> drMrc("Id") = ProcessId(txtLine) 'FindUser
> drMrc("Name") = ProcessName(txtLine)
> drMrc("Age") = ProcessAge(txtLine)
> dtMrc.Rows.Add(drMrc)
>
> dsMrc.Tables("Mrc").Rows.Add(drMrc)
> Loop Until txtLine Is Nothing
>
> Dim strFilter As String
>
> strFilter = "Id=" & FindUser
>
> dsMrc.Tables("Mrc").Select(strFilter)
>
> dgMarcacoes.DataSource = dsMrc
>
> LerLinha.Close()
> LerLinha = Nothing
>

code------------------------------------------------------------------------
> -----------------------
>
>
> What's wrong??????
>
> --
>
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
>
>



 
Reply With Quote
 
ruca
Guest
Posts: n/a
 
      03-03-2004
forget FindUser . In fact it's comment

ruca

"Felbrigg" <(E-Mail Removed)> escreveu na mensagem
news:(E-Mail Removed)...
> Maybe I'm missing something, but in the posted code, i dont think the
> "Finduser" variable is set.
>
> "ruca" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi gurus,
> > How can I filter data in my DataSet and then put the result in a

DataGrid?
> > NOTE: I'm reading a txt file into a dataset with 3 columns:
> >
> > Id, Name, Age
> >
> > I have this:
> >
> >
> >

>

code------------------------------------------------------------------------
> > -----------------------
> > LerLinha = New StreamReader(LerPath)
> >
> > dsMrc = New DataSet
> > dtMrc = New DataTable("Mrc")
> > dcMrc = New DataColumn("Id",
> > System.Type.GetType("System.String"))
> > dcMrc = New DataColumn("Name",
> > System.Type.GetType("System.String"))
> > dcMrc = New DataColumn("Age",
> > System.Type.GetType("System.String"))
> >
> > dtMrc.Columns.Add("Id")
> > dtMrc.Columns.Add("Name")
> > dtMrc.Columns.Add("Age")
> >
> > dsMrc.Tables.Add(dtMrc)
> >
> > Do
> > txtLine = LerLinha.ReadLine()
> >
> > drMrc = dtMrc.NewRow()
> > drMrc("Id") = ProcessId(txtLine) 'FindUser
> > drMrc("Name") = ProcessName(txtLine)
> > drMrc("Age") = ProcessAge(txtLine)
> > dtMrc.Rows.Add(drMrc)
> >
> > dsMrc.Tables("Mrc").Rows.Add(drMrc)
> > Loop Until txtLine Is Nothing
> >
> > Dim strFilter As String
> >
> > strFilter = "Id=" & FindUser
> >
> > dsMrc.Tables("Mrc").Select(strFilter)
> >
> > dgMarcacoes.DataSource = dsMrc
> >
> > LerLinha.Close()
> > LerLinha = Nothing
> >

>

code------------------------------------------------------------------------
> > -----------------------
> >
> >
> > What's wrong??????
> >
> > --
> >
> > Thank's (if you try to help me)
> > Hope this help you (if I try to help you)
> > ruca
> >
> >

>
>



 
Reply With Quote
 
ruca
Guest
Posts: n/a
 
      03-03-2004
But, how can I put it into a DataGrid?

"Martin Dechev" <(E-Mail Removed)> escreveu na mensagem
news:(E-Mail Removed)...
> <snip>
> > dsMrc.Tables("Mrc").Select(strFilter)

> <snip>
> > What's wrong??????

>
> The Select method on the DataTable class returns an array of DataRow

objects
> that match the filter criteria. You should use the returned array. The

call
> to Select doesn't modify the DataTable itself.
>
> Greetings
> Martin
>
>



 
Reply With Quote
 
ruca
Guest
Posts: n/a
 
      03-03-2004
The way I'm doing, nothing appears and I have Data there.


"Martin Dechev" <(E-Mail Removed)> escreveu na mensagem
news:(E-Mail Removed)...
> <snip>
> > dsMrc.Tables("Mrc").Select(strFilter)

> <snip>
> > What's wrong??????

>
> The Select method on the DataTable class returns an array of DataRow

objects
> that match the filter criteria. You should use the returned array. The

call
> to Select doesn't modify the DataTable itself.
>
> Greetings
> Martin
>
>



 
Reply With Quote
 
William Ryan eMVP
Guest
Posts: n/a
 
      03-03-2004
Ruca:


"ruca" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi gurus,
> How can I filter data in my DataSet and then put the result in a DataGrid?
> NOTE: I'm reading a txt file into a dataset with 3 columns:
>
> Id, Name, Age
>
> I have this:
>
>
>

code------------------------------------------------------------------------
> -----------------------
> LerLinha = New StreamReader(LerPath)
>
> dsMrc = New DataSet
> dtMrc = New DataTable("Mrc")
> dcMrc = New DataColumn("Id",
> System.Type.GetType("System.String"))
> dcMrc = New DataColumn("Name",
> System.Type.GetType("System.String"))
> dcMrc = New DataColumn("Age",
> System.Type.GetType("System.String"))
>
> dtMrc.Columns.Add("Id")
> dtMrc.Columns.Add("Name")
> dtMrc.Columns.Add("Age")
>
> dsMrc.Tables.Add(dtMrc)
>
> Do
> txtLine = LerLinha.ReadLine()
>
> drMrc = dtMrc.NewRow()
> drMrc("Id") = ProcessId(txtLine) 'FindUser
> drMrc("Name") = ProcessName(txtLine)
> drMrc("Age") = ProcessAge(txtLine)
> dtMrc.Rows.Add(drMrc)
>
> dsMrc.Tables("Mrc").Rows.Add(drMrc)
> Loop Until txtLine Is Nothing
>
> Dim strFilter As String
>
> strFilter = "Id=" & FindUser
>
> dsMrc.Tables("Mrc").Select(strFilter)
>
> dgMarcacoes.DataSource = dsMrc
>
> LerLinha.Close()
> LerLinha = Nothing
>

code------------------------------------------------------------------------
> -----------------------
>
>
> What's wrong??????
>
> --
>
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
>
>


you may want to consider binding the grid to a DataView which is based on a
DataTable in your Dataset and then just changing the rowfilter. If you do
this, the filtered data will be reflected immediately. Just set the Grid's
DataSource property to the DataView and use something like this
http://www.knowdotnet.com/articles/a...rowfilter.html


 
Reply With Quote
 
Carlos Campos
Guest
Posts: n/a
 
      03-03-2004
Could be like this....

Dim v as new DataView()
v.table = dsMrc.Tables("Mrc")
v.RowFilter = "Id=" & FindUser
dgMarcacoes.DataSource = v


"ruca" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi gurus,
> How can I filter data in my DataSet and then put the result in a DataGrid?
> NOTE: I'm reading a txt file into a dataset with 3 columns:
>
> Id, Name, Age
>
> I have this:
>
>
>

code------------------------------------------------------------------------
> -----------------------
> LerLinha = New StreamReader(LerPath)
>
> dsMrc = New DataSet
> dtMrc = New DataTable("Mrc")
> dcMrc = New DataColumn("Id",
> System.Type.GetType("System.String"))
> dcMrc = New DataColumn("Name",
> System.Type.GetType("System.String"))
> dcMrc = New DataColumn("Age",
> System.Type.GetType("System.String"))
>
> dtMrc.Columns.Add("Id")
> dtMrc.Columns.Add("Name")
> dtMrc.Columns.Add("Age")
>
> dsMrc.Tables.Add(dtMrc)
>
> Do
> txtLine = LerLinha.ReadLine()
>
> drMrc = dtMrc.NewRow()
> drMrc("Id") = ProcessId(txtLine) 'FindUser
> drMrc("Name") = ProcessName(txtLine)
> drMrc("Age") = ProcessAge(txtLine)
> dtMrc.Rows.Add(drMrc)
>
> dsMrc.Tables("Mrc").Rows.Add(drMrc)
> Loop Until txtLine Is Nothing
>
> Dim strFilter As String
>
> strFilter = "Id=" & FindUser
>
> dsMrc.Tables("Mrc").Select(strFilter)
>
> dgMarcacoes.DataSource = dsMrc
>
> LerLinha.Close()
> LerLinha = Nothing
>

code------------------------------------------------------------------------
> -----------------------
>
>
> What's wrong??????
>
> --
>
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
>
>



 
Reply With Quote
 
ruca
Guest
Posts: n/a
 
      03-03-2004
My drop it isn't show anything, and don't know why.

I understand your code, but not show.

Ruca


"Carlos Campos" <carlos@(NoSpam)costarricense.cr> escreveu na mensagem
news:(E-Mail Removed)...
> Could be like this....
>
> Dim v as new DataView()
> v.table = dsMrc.Tables("Mrc")
> v.RowFilter = "Id=" & FindUser
> dgMarcacoes.DataSource = v
>
>
> "ruca" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi gurus,
> > How can I filter data in my DataSet and then put the result in a

DataGrid?
> > NOTE: I'm reading a txt file into a dataset with 3 columns:
> >
> > Id, Name, Age
> >
> > I have this:
> >
> >
> >

>

code------------------------------------------------------------------------
> > -----------------------
> > LerLinha = New StreamReader(LerPath)
> >
> > dsMrc = New DataSet
> > dtMrc = New DataTable("Mrc")
> > dcMrc = New DataColumn("Id",
> > System.Type.GetType("System.String"))
> > dcMrc = New DataColumn("Name",
> > System.Type.GetType("System.String"))
> > dcMrc = New DataColumn("Age",
> > System.Type.GetType("System.String"))
> >
> > dtMrc.Columns.Add("Id")
> > dtMrc.Columns.Add("Name")
> > dtMrc.Columns.Add("Age")
> >
> > dsMrc.Tables.Add(dtMrc)
> >
> > Do
> > txtLine = LerLinha.ReadLine()
> >
> > drMrc = dtMrc.NewRow()
> > drMrc("Id") = ProcessId(txtLine) 'FindUser
> > drMrc("Name") = ProcessName(txtLine)
> > drMrc("Age") = ProcessAge(txtLine)
> > dtMrc.Rows.Add(drMrc)
> >
> > dsMrc.Tables("Mrc").Rows.Add(drMrc)
> > Loop Until txtLine Is Nothing
> >
> > Dim strFilter As String
> >
> > strFilter = "Id=" & FindUser
> >
> > dsMrc.Tables("Mrc").Select(strFilter)
> >
> > dgMarcacoes.DataSource = dsMrc
> >
> > LerLinha.Close()
> > LerLinha = Nothing
> >

>

code------------------------------------------------------------------------
> > -----------------------
> >
> >
> > What's wrong??????
> >
> > --
> >
> > Thank's (if you try to help me)
> > Hope this help you (if I try to help you)
> > ruca
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is Anti-Spam Filter.(thunderbird spam filter) zax75 Java 1 03-28-2008 06:43 AM
"rec.photo.digital.txt" Filter File Posted Online (for newsreadersthat can import a list of e-mail addresses to filter out) SMS 斯蒂文• 夏 Digital Photography 2 11-25-2007 11:00 AM
Polarising filter with UV filter? Stimp Digital Photography 23 11-17-2006 11:51 AM
to filter of not to filter Ken Digital Photography 2 12-23-2005 12:45 PM
UV Protector filter vs. Skylight filter? john Digital Photography 8 06-26-2004 03:44 PM



Advertisments