<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tally Rows in a DataSet that Match a Condition</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/27/tally-rows-in-a-dataset-that-match-a-condition.aspx</link><description>Today I got a question that comes up often in data application programming about how to count rows in a DataSet that matched a condition. The DataSet may be bound to a DataGridView or other list control and it’s tempting to start looking at the control</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Tally Rows in a DataSet that Match a Condition | ASP NET Hosting</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/27/tally-rows-in-a-dataset-that-match-a-condition.aspx#9572803</link><pubDate>Tue, 28 Apr 2009 05:43:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9572803</guid><dc:creator>Tally Rows in a DataSet that Match a Condition | ASP NET Hosting</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://asp-net-hosting.simplynetdev.com/tally-rows-in-a-dataset-that-match-a-condition/"&gt;http://asp-net-hosting.simplynetdev.com/tally-rows-in-a-dataset-that-match-a-condition/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Tally Rows in a DataSet that Match a Condition</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/27/tally-rows-in-a-dataset-that-match-a-condition.aspx#9572854</link><pubDate>Tue, 28 Apr 2009 06:29:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9572854</guid><dc:creator>Jimmy Ye Htut</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have a question. How do you get these snippet? Are those your own?&lt;/p&gt;</description></item><item><title>re: Tally Rows in a DataSet that Match a Condition</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/27/tally-rows-in-a-dataset-that-match-a-condition.aspx#9573800</link><pubDate>Tue, 28 Apr 2009 19:37:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9573800</guid><dc:creator>Beth Massi</dc:creator><description>&lt;p&gt;Hi Jimmy,&lt;/p&gt;
&lt;p&gt;Snippets are included in VS2005 and VS2008. I'm showing the VS2008 version. You can also edit and create your own snippets with the Code Snippet Editor: &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/vbasic/bb973770.aspx"&gt;http://msdn.microsoft.com/en-us/vbasic/bb973770.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;-B&lt;/p&gt;
</description></item><item><title>re: Tally Rows in a DataSet that Match a Condition</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/27/tally-rows-in-a-dataset-that-match-a-condition.aspx#9651756</link><pubDate>Fri, 29 May 2009 07:42:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9651756</guid><dc:creator>EL</dc:creator><description>&lt;p&gt;Hai, Beth.&lt;/p&gt;
&lt;p&gt;I Have a question. How is the code if I don't use typed dataset? In other words, I don't use drag and drop, since I have difficulty if there is a problem rising with typed dataset.&lt;/p&gt;
&lt;p&gt; I know You always use drag and drop in creating and manipulating database application in article or video. However, perhaps you may use purely code in stating the current row with bindindsource.&lt;/p&gt;
&lt;p&gt;Thanks in advanced.&lt;/p&gt;</description></item><item><title>re: Tally Rows in a DataSet that Match a Condition</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/27/tally-rows-in-a-dataset-that-match-a-condition.aspx#9651766</link><pubDate>Fri, 29 May 2009 07:46:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9651766</guid><dc:creator>EL</dc:creator><description>&lt;p&gt;Hai, Beth.&lt;/p&gt;
&lt;p&gt;I Have a question. How is the code if I don't use typed dataset? In other words, I don't use drag and drop, since I have difficulty if there is a problem rising with typed dataset.&lt;/p&gt;
&lt;p&gt; I know You always use drag and drop in creating and manipulating database application in article or video. However, perhaps you may use purely code in stating the current row with bindindsource.&lt;/p&gt;
&lt;p&gt;Thanks in advanced.&lt;/p&gt;</description></item><item><title>re: Tally Rows in a DataSet that Match a Condition</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/27/tally-rows-in-a-dataset-that-match-a-condition.aspx#9685754</link><pubDate>Tue, 02 Jun 2009 18:50:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9685754</guid><dc:creator>Beth Massi</dc:creator><description>&lt;p&gt;Hi El,&lt;/p&gt;
&lt;p&gt;You still can grab the position from the BindingSource if you are binding to an untyped DataSet/DataTable as well. You just have to deal with converting the values in the rows because you don't have a schema. If your UI is purely dynamic you can end up in this situation, but if you have known properties it's much easier to work with typed datasets and objects. Designer support for data-binding is just one benefit. &lt;/p&gt;
&lt;p&gt;Dim dt As New DataTable&lt;/p&gt;
&lt;p&gt;' create columns and fill rows ...&lt;/p&gt;
&lt;p&gt;Me.BindingSource1.DataSource = dt&lt;/p&gt;
&lt;p&gt;'.... &lt;/p&gt;
&lt;p&gt;Private Sub BindingSource1_PositionChanged() Handles BindingSource1.PositionChanged&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;'Get the current row&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Dim row As DataRow&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;row = CType(CType(Me.BindingSource1.Current, DataRowView).Row, DataRow)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;MsgBox(row(&amp;quot;Column1&amp;quot;).ToString())&lt;/p&gt;
&lt;p&gt;End Sub&lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;-B&lt;/p&gt;
</description></item><item><title>re: Tally Rows in a DataSet that Match a Condition</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/27/tally-rows-in-a-dataset-that-match-a-condition.aspx#9686676</link><pubDate>Tue, 02 Jun 2009 22:47:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9686676</guid><dc:creator>Joe</dc:creator><description>&lt;p&gt;Hi beth&lt;/p&gt;
&lt;p&gt;I want to be able to use linq to get a certain recordset from an xml file and then put those results into a datagridview. my code looks like this&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Dim myPlayer = XDocument.Load(strPath &amp;amp; &amp;quot;\08Stats.xml&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Dim xmlPlayer = &amp;lt;Player&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;%= From Player In myPlayer...&amp;lt;row&amp;gt; _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Where Player.&amp;lt;PlID&amp;gt;.Value = intPlayerID _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Select Player %&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Player&amp;gt;&lt;/p&gt;
&lt;p&gt;Me.dgvPlayerStats.DataSource = xmlPlayer&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Me.dgvPlayerStats.DataBind()&lt;/p&gt;
&lt;p&gt;obviously this doesnt work. &amp;nbsp;I want to be able to query an xml doc and put the results of that query in a datagridview. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for your time.&lt;/p&gt;
&lt;p&gt;Joe&lt;/p&gt;</description></item><item><title>re: Tally Rows in a DataSet that Match a Condition</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/27/tally-rows-in-a-dataset-that-match-a-condition.aspx#9687914</link><pubDate>Wed, 03 Jun 2009 02:58:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9687914</guid><dc:creator>Beth Massi</dc:creator><description>&lt;p&gt;Hi Joe,&lt;/p&gt;
&lt;p&gt;Try creating a list of objects from your query instead. You're creating an XElement here and you can't bind this control to that. Try something like this:&lt;/p&gt;
&lt;p&gt;Dim resultPlayers = _&lt;/p&gt;
&lt;p&gt; &amp;nbsp;From Player In myPlayer...&amp;lt;row&amp;gt; _&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Where Player.&amp;lt;PlID&amp;gt;.Value = intPlayerID _&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Select Player.&amp;lt;PID&amp;gt;.Value, _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Player.&amp;lt;Property1&amp;gt;.Value, ...rest of columns&lt;/p&gt;
&lt;p&gt;Me.dgvPlayerStats.DataSOurce = resultPlayers.ToList()&lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;-B&lt;/p&gt;
</description></item></channel></rss>