<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-7715929993952066683</atom:id><lastBuildDate>Mon, 07 Oct 2024 04:06:48 +0000</lastBuildDate><title>Just the Code Please:  ASP.NET using C#</title><description></description><link>http://just-the-code.blogspot.com/</link><managingEditor>noreply@blogger.com (vablaza)</managingEditor><generator>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7715929993952066683.post-7115388480317944225</guid><pubDate>Tue, 08 Apr 2008 14:15:00 +0000</pubDate><atom:updated>2008-11-12T20:02:10.526-08:00</atom:updated><title>Dynamically Popluating a ListBox with SQL Data Adapter</title><description>&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;This snippet shows you a simple way to dynamically populate a ListBox. Your SQL Select statement will determine the data that the ListBox&#39;s will display as well as its value.           &lt;/span&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//declare two variables - one for the connection string and the other for the dataset&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String&lt;/span&gt; cnstr;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt; ds;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;        &lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color:blue;&quot;&gt;object&lt;/span&gt; sender,&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Call the method you created&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;_source();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;            &lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;void&lt;/span&gt; _source()&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Setup Connection string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;cnstr= &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;server=type in IP address;user=type in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;database user;password=type in database password;&quot;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt; &quot;database=type in database &lt;/span&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;name;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Create a new Sql Connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt; cn = &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt;(cn&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;str);&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create the DataSet&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;ds = new &lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;ds&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;);&lt;/span&gt;&lt;/p&gt;                  &lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new Sql Data Adapter&lt;br /&gt;//In your SQL Select statement, only select&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt; the c&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;olumns you want to be displayed&lt;br /&gt;//If you use the select all (*) it will obviously display all the columns&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt; da= &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;SELECT columname FROM tablename&quot;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;, cn&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Fill the Data Adapter&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;da.Fill(ds);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the Datasource for the Repeater equal to the DataSet&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;ListBox1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataSource = ds;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the ListBox&#39;s DataTextField and DataValueField to the Column you selected&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;ListBox1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataTextField = &lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;columnname&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;ListBox1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataValueField = &lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;columnname&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Bind your Data&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;ListBox1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataBind();&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-size:130%;&quot; &gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;*&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;Quick Note&lt;/span&gt;: Don&#39;t forget to add &#39;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;using&lt;/span&gt; Syste&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;m.Data.SqlClient;&#39; to the top of the code behind page.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;In your .aspx page add the following code in between the body tags.  &lt;span style=&quot;font-weight: bold;&quot;&gt;Click on the image to view full size&lt;/span&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNfvK60n96LVJw5XknDEL-QWysf9C0nQZ0B3cF3ApMj4CV9941B84hLFBThsuPT7hyBN8sXSkzXLaDy2uR_4ZWPPQPvQL9BtFpNVK1tNuDlgC3_pfLl59wyK4C1aBksbNP6sN01brJsOM/s1600-h/listbox.bmp&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNfvK60n96LVJw5XknDEL-QWysf9C0nQZ0B3cF3ApMj4CV9941B84hLFBThsuPT7hyBN8sXSkzXLaDy2uR_4ZWPPQPvQL9BtFpNVK1tNuDlgC3_pfLl59wyK4C1aBksbNP6sN01brJsOM/s400/listbox.bmp&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5186878815794375682&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p face=&quot;arial&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;If you have any questions or there are dis&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;crepancies in the code please feel free to leave a comment and I will try to answer/fix them as soon as I can.&lt;/span&gt;&lt;/p&gt;</description><link>http://just-the-code.blogspot.com/2008/04/dynamically-popluating-listbox-with-sql.html</link><author>noreply@blogger.com (vablaza)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNfvK60n96LVJw5XknDEL-QWysf9C0nQZ0B3cF3ApMj4CV9941B84hLFBThsuPT7hyBN8sXSkzXLaDy2uR_4ZWPPQPvQL9BtFpNVK1tNuDlgC3_pfLl59wyK4C1aBksbNP6sN01brJsOM/s72-c/listbox.bmp" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7715929993952066683.post-6071897980865092040</guid><pubDate>Mon, 07 Apr 2008 16:57:00 +0000</pubDate><atom:updated>2008-11-12T20:02:10.767-08:00</atom:updated><title>Dynamically Popluating a DropDownList with SQL Data Adapter</title><description>&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;This snippet shows you a simple way to dynamically populate a DropDownList. Your SQL Select statement will determine the data that the DropDownList&#39;s will display as well as its value.           &lt;/span&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//declare two variables - one for the connection string and the other for the dataset&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String&lt;/span&gt; cnstr;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt; ds;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;        &lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color:blue;&quot;&gt;object&lt;/span&gt; sender,&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Call the method you created&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;_source();&lt;br /&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;            &lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;void&lt;/span&gt; _source()&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Setup Connection string&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;cnstr= &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;server=type in IP address;user=type in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;database user;password=type in database password;&quot;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt; &quot;database=type in database &lt;/span&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;name;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Create a new Sql Connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt; cn = &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt;(cnstr);&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create the DataSet&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;ds = new &lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;ds&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;);&lt;/span&gt;&lt;/p&gt;                  &lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new Sql Data Adapter&lt;br /&gt;//In your SQL Select statement, only select the c&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;olumns you want to be displayed&lt;br /&gt;//If you use the select all (*) it will obviously display all the columns&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt; da= &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;SELECT columname FROM tablename&quot;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;, cn&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Fill the Data Adapter&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;da.Fill(ds);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the Datasource for the Repeater equal to the DataSet&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;DropDownList1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataSource = ds;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the DropDownList&#39;s DataTextField and DataValueField to the Column you selected&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;DropDownList1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataTextField = &lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;columnname&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;DropDownList1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataValueField = &lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;columnname&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Bind your Data&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;DropDownList1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataBind();&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-size:130%;&quot; &gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;*&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;Quick Note&lt;/span&gt;: Don&#39;t forget to add &#39;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;using&lt;/span&gt; Syste&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;m.Data.SqlClient;&#39; to the top of the code behind page.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;In your .aspx page add the following code in between the body tags.  &lt;span style=&quot;font-weight: bold;&quot;&gt;Click on the image to view full size&lt;/span&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgledaQY5Ll6sJ8RlYIL8POYC7a2Uk8eIg7vFakmFCBjlNPEKyiVpKCn2cOjsLjLuDM-Mvcs9eCC7gYxkKNBUyb2StE31nKqa2gRJfYDnym_uGdLrXikNO1N8AeZDTseKPtlG8CjJ0uOnY/s1600-h/dropdownlist.bmp&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgledaQY5Ll6sJ8RlYIL8POYC7a2Uk8eIg7vFakmFCBjlNPEKyiVpKCn2cOjsLjLuDM-Mvcs9eCC7gYxkKNBUyb2StE31nKqa2gRJfYDnym_uGdLrXikNO1N8AeZDTseKPtlG8CjJ0uOnY/s400/dropdownlist.bmp&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5186551977373084658&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p face=&quot;arial&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;If you have any questions or there are dis&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;crepancies in the code please feel free to leave a comment and I will try to answer/fix them as soon as I can.&lt;/span&gt;&lt;/p&gt;</description><link>http://just-the-code.blogspot.com/2008/04/dynamically-popluating-dropdownlist.html</link><author>noreply@blogger.com (vablaza)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgledaQY5Ll6sJ8RlYIL8POYC7a2Uk8eIg7vFakmFCBjlNPEKyiVpKCn2cOjsLjLuDM-Mvcs9eCC7gYxkKNBUyb2StE31nKqa2gRJfYDnym_uGdLrXikNO1N8AeZDTseKPtlG8CjJ0uOnY/s72-c/dropdownlist.bmp" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7715929993952066683.post-5447718996084068981</guid><pubDate>Thu, 20 Mar 2008 23:49:00 +0000</pubDate><atom:updated>2008-11-12T20:02:10.966-08:00</atom:updated><title>Inserting Data into a Database using OleDb</title><description>&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;This snippet is shows you a simple way to insert data into a database using OleDb.&lt;br /&gt;&lt;/span&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;void&lt;/span&gt; Button1_Click(&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Setup Connection string&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String &lt;/span&gt;cnstr= &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;Provider=type in OLE DB Provider;server=type in IP address;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+ &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;Uid=type in database user;Pwd=type in database password;&quot;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt; &quot;database=type in database &lt;/span&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;name;&quot;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new OleDbConnection&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;OleDbConnection &lt;/span&gt;cn = &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;OleDbConnection&lt;/span&gt;(cnstr);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a SQL insert statement&lt;br /&gt;//Don&#39;t forget to concatenate when using TextBox1.Text&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String &lt;/span&gt;insert = &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;INSERT INTO table name &lt;table-name&gt;(column name&lt;column&gt;) VALUES (&#39;&quot;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+ TextBox1.Text + &lt;/span&gt;&quot;&#39;)&quot;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;;&lt;/span&gt;&lt;/column&gt;&lt;/table-name&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new OleDbCommand&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;OleDbCommand &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;insertcmd = &lt;/span&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new &lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;OleDbCommand &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(insert, cn);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Open the connection&lt;br /&gt;&lt;/span&gt;cn.Open();&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;&lt;br /&gt;//Execute the Query&lt;br /&gt;&lt;/span&gt;insertcmd.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Close the connection&lt;br /&gt;&lt;/span&gt;cn.Close();&lt;br /&gt;} &lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;*&lt;span style=&quot;color: rgb(255, 0, 0); font-weight: bold;&quot;&gt;Quick Note&lt;/span&gt;: Don&#39;t forget to add &#39;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;using&lt;/span&gt; System.Data.OleDb;&#39; to the top of the code behind page.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;In your .aspx page add the following code in between the body tags.  &lt;span style=&quot;font-weight: bold;&quot;&gt;Click on the image to view full size&lt;/span&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsBm7Xq-vFo92gtZxmmAENarnl-iAHYaCfEDubyt7Ximqdi3yKLhiL0p5Gngf6xYuzx-FYFQXpIuVg4aQTMmR6ynxVc937hXpftu1mcPwL984G-SuNdLVsOV7YmGovTSaSwlr1t5tnI3o/s1600-h/insertoledb.bmp&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsBm7Xq-vFo92gtZxmmAENarnl-iAHYaCfEDubyt7Ximqdi3yKLhiL0p5Gngf6xYuzx-FYFQXpIuVg4aQTMmR6ynxVc937hXpftu1mcPwL984G-SuNdLVsOV7YmGovTSaSwlr1t5tnI3o/s400/insertoledb.bmp&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5179989692546558946&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;If you have any questions or there are discrepancies in the code please feel free to leave a comment and I will try to answer/fix them as soon as I can.&lt;/span&gt;&lt;/p&gt;</description><link>http://just-the-code.blogspot.com/2008/03/inserting-data-into-database-using.html</link><author>noreply@blogger.com (vablaza)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsBm7Xq-vFo92gtZxmmAENarnl-iAHYaCfEDubyt7Ximqdi3yKLhiL0p5Gngf6xYuzx-FYFQXpIuVg4aQTMmR6ynxVc937hXpftu1mcPwL984G-SuNdLVsOV7YmGovTSaSwlr1t5tnI3o/s72-c/insertoledb.bmp" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7715929993952066683.post-8370442925719013104</guid><pubDate>Tue, 18 Mar 2008 20:13:00 +0000</pubDate><atom:updated>2008-11-12T20:02:11.200-08:00</atom:updated><title>Dynamically Populating a Gridview with a Search Button and  aTextbox</title><description>&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;This snippet shows you a simple way to dynamically populate a GridView with a search button and a textbox. Your SQL Select statement will determine which columns you want displayed in your GridView.          &lt;/span&gt;&lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//declare two variables - one for the connection string and the other for the dataset&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String&lt;/span&gt; cnstr;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt; ds;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;        &lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color:blue;&quot;&gt;object&lt;/span&gt; sender,&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;Label1.Text = &lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;            &lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;void&lt;/span&gt; Button1_Click(&lt;span style=&quot;color:blue;&quot;&gt;object&lt;/span&gt; sender,&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Setup Connection string&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;cnstr= &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;server=type in IP address;user=type in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;database user;password=type in database password;&quot;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt; &quot;database=type in database &lt;/span&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;name;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Create a new Sql Connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt; cn = &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt;(cnstr);&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create the DataSet&lt;/span&gt;&lt;br /&gt;ds = new &lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;ds&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;            &lt;p class=&quot;MsoNormal&quot;  style=&quot;margin-bottom: 0.0001pt; line-height: normal;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new Sql Data Adapter&lt;br /&gt;//In your SQL Select statement, only select the c&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;olumns you want to be displayed&lt;br /&gt;//If you use the select all (*) it will obviously display all the columns&lt;br /&gt;//Don&#39;t forget to concatenate when using TextBox1.Text&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt; da= &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;&lt;/span&gt;(&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;SELECT columname FROM tablename WHERE VendorID LIKE &#39;&quot;  &lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+ TextBox1.Text +&lt;/span&gt; &quot;&#39;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;, cn&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(163, 21, 21);&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Fill the Data Adapter&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;da.Fill(ds);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the Datasource for the Repeater equal to the DataSet&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;GridView1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataSource = ds;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Bind your Data&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;GridView1&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;.DataBind();&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;/p&gt;      &lt;p class=&quot;MsoNormal&quot;  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;Label1.Text = GridView1.Rows.Count.ToString();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 115%;font-size:130%;&quot; &gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;*&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;Quick Note&lt;/span&gt;: Don&#39;t forget to add &#39;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;using&lt;/span&gt; System.Data.SqlClient;&#39; to the top of the code behind page.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;In your .aspx page add the following code in between the body tags.  &lt;span style=&quot;font-weight: bold;&quot;&gt;Click on the image to view full size&lt;/span&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p face=&quot;arial&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigsTM4ndP_fcQqMCflr8LfJqy38zNw8H-k5LeGYGwTBCilnyf4mCIE_pv2I-Kby4NimYUZ8tcNbtFHBOPlwiEMASsYJQH5qWnIl-2JD0Xjd5lNCbfUwC1rvP0IN2ipJsYCCOh05nVZe5g/s1600-h/gridviewWsearch.bmp&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigsTM4ndP_fcQqMCflr8LfJqy38zNw8H-k5LeGYGwTBCilnyf4mCIE_pv2I-Kby4NimYUZ8tcNbtFHBOPlwiEMASsYJQH5qWnIl-2JD0Xjd5lNCbfUwC1rvP0IN2ipJsYCCOh05nVZe5g/s400/gridviewWsearch.bmp&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5179919469831269266&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;font-family: arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;If you have any questions or there are dis&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;crepancies in the code please feel free to leave a comment and I will try to answer/fix them as soon as I can.&lt;/span&gt;&lt;/p&gt;</description><link>http://just-the-code.blogspot.com/2008/03/dynamically-populating-gridview-with_18.html</link><author>noreply@blogger.com (vablaza)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigsTM4ndP_fcQqMCflr8LfJqy38zNw8H-k5LeGYGwTBCilnyf4mCIE_pv2I-Kby4NimYUZ8tcNbtFHBOPlwiEMASsYJQH5qWnIl-2JD0Xjd5lNCbfUwC1rvP0IN2ipJsYCCOh05nVZe5g/s72-c/gridviewWsearch.bmp" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7715929993952066683.post-2101181731707321900</guid><pubDate>Mon, 17 Mar 2008 20:33:00 +0000</pubDate><atom:updated>2008-11-12T20:02:11.343-08:00</atom:updated><title>Dynamically Populating a Repeater with SQL Data Adapter</title><description>&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;This snippet shows you a simple way to dynamically populate a Repeater. Your SQL Select statement will determine which columns you want displayed in your Repeater&lt;/span&gt;&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;.&lt;/span&gt; &lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//declare two variables - one for the connection string and the other for the dataset&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String&lt;/span&gt; cnstr;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt; ds;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Setup Connection string&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;cnstr= &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;server=type in IP address;user=type in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;database user;password=type in database password;&quot;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt; &quot;database=type in database &lt;/span&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;name;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Create a new Sql Connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt; cn = &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt;(cnstr);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create the DataSet&lt;/span&gt;&lt;br /&gt;ds = new &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt;(&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;ds&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new Sql Data Adapter&lt;br /&gt;//In your SQL Select statement, only select the c&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;olumns you want to be displayed&lt;br /&gt;//If you use the select all (*) it will obviously display all the columns&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt; da= &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt;( &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;SELECT columname FROM tablename&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;&lt;/span&gt; , cn);&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Fill the Data Adapter&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;da.Fill(ds);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the Datasource for the Repeater equal to the DataSet&lt;br /&gt;&lt;/span&gt;Repeater1.DataSource = ds;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Bind your Data&lt;br /&gt;&lt;/span&gt;Repeater1.DataBind();&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;*&lt;span style=&quot;color: rgb(255, 0, 0); font-weight: bold;&quot;&gt;Quick Note&lt;/span&gt;: Don&#39;t forget to add &#39;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;using&lt;/span&gt; System.Data.SqlClient;&#39; to the top of the code behind page.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;In your .aspx page add the following code in between the body tags. Depending on how many feilds/columns you want to display, will determine how many controls you use. In this example I use a Label to display the data, you don&#39;t have to use a Label, you can use another control, such as a TextBox, if you cho&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;ose to.  &lt;span style=&quot;font-weight: bold;&quot;&gt;Click on the image to view full size.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7Yzgp4aoKn1kHajREkcwXCFRrgfJa_zGZ1mD5ZVZ1quXJ_WSlQHkbmshI6-KfcXWgWA50mny32aLclPJahwPSqJe63ZeTWQaSyhBswOjxQLjFYS9N62822q5H6AI_Gk8eqW41fFO9ZPo/s1600-h/repeater.bmp&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7Yzgp4aoKn1kHajREkcwXCFRrgfJa_zGZ1mD5ZVZ1quXJ_WSlQHkbmshI6-KfcXWgWA50mny32aLclPJahwPSqJe63ZeTWQaSyhBswOjxQLjFYS9N62822q5H6AI_Gk8eqW41fFO9ZPo/s400/repeater.bmp&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5179918245765589890&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;If you have any questions or there are discrepancies in the code please feel free to leave a comment and I will try to answer/fix them as soon as I can.&lt;/span&gt;&lt;/p&gt;</description><link>http://just-the-code.blogspot.com/2008/03/dynamically-populating-repeater-with.html</link><author>noreply@blogger.com (vablaza)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7Yzgp4aoKn1kHajREkcwXCFRrgfJa_zGZ1mD5ZVZ1quXJ_WSlQHkbmshI6-KfcXWgWA50mny32aLclPJahwPSqJe63ZeTWQaSyhBswOjxQLjFYS9N62822q5H6AI_Gk8eqW41fFO9ZPo/s72-c/repeater.bmp" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7715929993952066683.post-1274624658628240985</guid><pubDate>Mon, 17 Mar 2008 20:33:00 +0000</pubDate><atom:updated>2008-11-12T20:02:11.596-08:00</atom:updated><title>Dynamically Populating a FormView with SQL Data Adapter</title><description>&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;This snippet shows you a simple way to dynamically populate a FormView. Your SQL Select statement will determine which columns you want displayed in your &lt;/span&gt;&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;FormView&lt;/span&gt;&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;.&lt;/span&gt; &lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//declare two variables - one for the connection string and the other for the dataset&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String&lt;/span&gt; cnstr;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt; ds;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Setup Connection string&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;cnstr= &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;server=type in IP address;user=type in database user;password=type in database password;&quot;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt; &quot;database=type in database &lt;/span&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;name;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Create a new Sql Connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt; cn = &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt;(cnstr);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create the DataSet&lt;/span&gt;&lt;br /&gt;ds = new &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt;(&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;ds&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new Sql Data Adapter&lt;br /&gt;//In your SQL Select statement, only select the columns you want to be displayed&lt;br /&gt;//If you use the select all (*) it will obviously display all the columns&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt; da= &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt;( &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;Your Select Statement&quot;&lt;/span&gt; , cn);&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Fill the Data Adapter&lt;br /&gt;&lt;/span&gt;da.Fill(ds);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the Datasource for the FormView equal to the DataSet&lt;br /&gt;&lt;/span&gt;FormView1.DataSource = ds;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Bind your Data&lt;br /&gt;&lt;/span&gt;FormView1.DataBind();&lt;br /&gt;} &lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;*&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;Quick Note&lt;/span&gt;: Don&#39;t forget to add &#39;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;using&lt;/span&gt; System.Data.SqlClient;&#39; to the top of the code behind page.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;In your .aspx page add the following code in between the body tags. Depending on how many feilds/columns you want to display, will determine how many controls you use. In this example I use a Label to display the data, you don&#39;t have to use a Label, you can use another control, such as a TextBox, if you choose to.  &lt;span style=&quot;font-weight: bold;&quot;&gt;Click on the image to view full size&lt;/span&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5fOOqRfxzU7PI1ilE2N2FayHKI-jeDoRYDAIbZ5IE8QTJEWLHLsPBdNuKM9IQeiiSJkOqat6cmnf5bWioRoCDZwlraxzR9MqcnN0bVPupdySa7llyIGzsE9y64a_ZDfyQQKMrbnYlXgQ/s1600-h/formview.bmp&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5fOOqRfxzU7PI1ilE2N2FayHKI-jeDoRYDAIbZ5IE8QTJEWLHLsPBdNuKM9IQeiiSJkOqat6cmnf5bWioRoCDZwlraxzR9MqcnN0bVPupdySa7llyIGzsE9y64a_ZDfyQQKMrbnYlXgQ/s400/formview.bmp&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5179921540005505954&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p face=&quot;arial&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;If you have any questions or there are discrepancies in the code please feel free to leave a comment and I will try to answer/fix them as soon as I can.&lt;/span&gt;&lt;/p&gt;</description><link>http://just-the-code.blogspot.com/2008/03/dynamically-populating-formview-with.html</link><author>noreply@blogger.com (vablaza)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5fOOqRfxzU7PI1ilE2N2FayHKI-jeDoRYDAIbZ5IE8QTJEWLHLsPBdNuKM9IQeiiSJkOqat6cmnf5bWioRoCDZwlraxzR9MqcnN0bVPupdySa7llyIGzsE9y64a_ZDfyQQKMrbnYlXgQ/s72-c/formview.bmp" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7715929993952066683.post-7118846946938948107</guid><pubDate>Mon, 17 Mar 2008 20:33:00 +0000</pubDate><atom:updated>2008-11-12T20:02:11.781-08:00</atom:updated><title>Dynamically Populating a DetailsView with SQL Data Adapter</title><description>&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;This snippet shows you a simple way to dynamically populate a DetailsView. Your SQL Select statement will determine which columns you want displayed in your &lt;/span&gt;&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;DetailsView&lt;/span&gt;&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;.&lt;/span&gt; &lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//declare two variables - one for the connection string and the other for the dataset&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String&lt;/span&gt; cnstr;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt; ds;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Setup Connection string&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;cnstr= &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;server=type in IP address;user=type in database user;password=type in database password;&quot;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt; &quot;database=type in database &lt;/span&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;name;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Create a new Sql Connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt; cn = &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt;(cnstr);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create the DataSet&lt;/span&gt;&lt;br /&gt;ds = new &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt;(&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;ds&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new Sql Data Adapter&lt;br /&gt;//In your SQL Select statement, only select the columns you want to be displayed&lt;br /&gt;//If you use the select all (*) it will obviously display all the columns&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt; da= &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt;( &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;Your Select Statement&quot;&lt;/span&gt; , cn);&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Fill the Data Adapter&lt;br /&gt;&lt;/span&gt;da.Fill(ds);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the Datasource for the DetailsView equal to the DataSet&lt;br /&gt;&lt;/span&gt;DetailsView1.DataSource = ds;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Bind your Data&lt;br /&gt;&lt;/span&gt;DetailsView1.DataBind();&lt;br /&gt;} &lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;*&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;Quick Note&lt;/span&gt;: Don&#39;t forget to add &#39;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;using&lt;/span&gt; System.Data.SqlClient;&#39; to the top of the code behind page.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;In your .aspx page add the following code in between the body tags. In addition, you don&#39;t have to use a Label, you can use a Textbox if you choose to.  &lt;span style=&quot;font-weight: bold;&quot;&gt;Click on the image to view full size&lt;/span&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilrBSa-eYmcwbSLGJFL_mH9QBnA7rlZetYj8tcGCt-MnPDIJUGSCIx05yaJGI4ZbrCMnAND48OcOlMC0COQ_IGqgdG9trgzf73-wQjE0ac6mbv_hJsNW7eidsneDBGeuq6HrvRMI3wjh0/s1600-h/detailsview.bmp&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilrBSa-eYmcwbSLGJFL_mH9QBnA7rlZetYj8tcGCt-MnPDIJUGSCIx05yaJGI4ZbrCMnAND48OcOlMC0COQ_IGqgdG9trgzf73-wQjE0ac6mbv_hJsNW7eidsneDBGeuq6HrvRMI3wjh0/s400/detailsview.bmp&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5179922450538572722&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;font-family: arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p face=&quot;arial&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;If you have any questions or there are discrepancies in the code please feel free to leave a comment and I will try to answer/fix them as soon as I can.&lt;/span&gt;&lt;/p&gt;</description><link>http://just-the-code.blogspot.com/2008/03/dynamically-populating-detailsview-with.html</link><author>noreply@blogger.com (vablaza)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilrBSa-eYmcwbSLGJFL_mH9QBnA7rlZetYj8tcGCt-MnPDIJUGSCIx05yaJGI4ZbrCMnAND48OcOlMC0COQ_IGqgdG9trgzf73-wQjE0ac6mbv_hJsNW7eidsneDBGeuq6HrvRMI3wjh0/s72-c/detailsview.bmp" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7715929993952066683.post-648607932760538713</guid><pubDate>Mon, 17 Mar 2008 20:33:00 +0000</pubDate><atom:updated>2008-11-12T20:02:11.949-08:00</atom:updated><title>Dynamically Populating a DataList with SQL Data Adapter</title><description>&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;This snippet shows you a simple way to dynamically populate a DataList. Your SQL Select statement will determine which columns you want displayed in your &lt;/span&gt;&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;DataList.&lt;/span&gt; &lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//declare two variables - one for the connection string and the other for the dataset&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String&lt;/span&gt; cnstr;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt; ds;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Setup Connection string&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;cnstr= &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;server=type in IP address;user=type in database user;password=type in database password;&quot;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt; &quot;database=type in database &lt;/span&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;name;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Create a new Sql Connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt; cn = &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt;(cnstr);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create the DataSet&lt;/span&gt;&lt;br /&gt;ds = new &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt;(&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;ds&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new Sql Data Adapter&lt;br /&gt;//In your SQL Select statement, only select the columns you want to be displayed&lt;br /&gt;//If you use the select all (*) it will obviously display all the columns&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt; da= &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt;( &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;Your Select Statement&quot;&lt;/span&gt; , cn);&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Fill the Data Adapter&lt;br /&gt;&lt;/span&gt;da.Fill(ds);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the Datasource for the DataList equal to the DataSet&lt;br /&gt;&lt;/span&gt;DataList1.DataSource = ds;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Bind your Data&lt;br /&gt;&lt;/span&gt;DataList.DataBind();&lt;br /&gt;} &lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;*&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;Quick Note&lt;/span&gt;: Don&#39;t forget to add &#39;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;using&lt;/span&gt; System.Data.SqlClient;&#39; to the top of the code behind page.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;In your .aspx page add the following code in between the body tags. Depending on how many feilds/columns you want to display, will determine how many controls you use. In this example I use a Label to display the data, you don&#39;t have to use a Label, you can use another control, such as a TextBox, if you choose to.  &lt;span style=&quot;font-weight: bold;&quot;&gt;Click on the image to view full size&lt;/span&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;p face=&quot;arial&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1yT28ghV0xJqEgFvdrSSd1gPZavpEkkjbXIQTMwI7LB85Tp1zEJVMKpBxhq6gHLJ-Cj5dQTMGn8d6H-qtgDc5IpYVQ4iVDR1jHibbwaFpJdPSjMuPQpCiJiJwvkHir8EI-iB8KKK4UBQ/s1600-h/datalist.bmp&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1yT28ghV0xJqEgFvdrSSd1gPZavpEkkjbXIQTMwI7LB85Tp1zEJVMKpBxhq6gHLJ-Cj5dQTMGn8d6H-qtgDc5IpYVQ4iVDR1jHibbwaFpJdPSjMuPQpCiJiJwvkHir8EI-iB8KKK4UBQ/s400/datalist.bmp&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5179923597294840770&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;font-family: arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;If you have any questions or there are discrepancies in the code please feel free to leave a comment and I will try to answer/fix them as soon as I can.&lt;/span&gt;&lt;/p&gt;</description><link>http://just-the-code.blogspot.com/2008/03/dynamically-populating-datalist-with.html</link><author>noreply@blogger.com (vablaza)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1yT28ghV0xJqEgFvdrSSd1gPZavpEkkjbXIQTMwI7LB85Tp1zEJVMKpBxhq6gHLJ-Cj5dQTMGn8d6H-qtgDc5IpYVQ4iVDR1jHibbwaFpJdPSjMuPQpCiJiJwvkHir8EI-iB8KKK4UBQ/s72-c/datalist.bmp" height="72" width="72"/><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7715929993952066683.post-6208857724182945705</guid><pubDate>Mon, 17 Mar 2008 20:32:00 +0000</pubDate><atom:updated>2008-11-12T20:02:12.114-08:00</atom:updated><title>Dynamically Populating a Gridview with SQL Data Adapter</title><description>&lt;span style=&quot;;font-family:arial;font-size:130%;&quot;  &gt;This snippet shows you a simple way to dynamically populate a GridView. Your SQL Select statement will determine which columns you want displayed in your GridView.&lt;/span&gt; &lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//declare two variables - one for the connection string and the other for the dataset&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String&lt;/span&gt; cnstr;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt; ds;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Setup Connection string&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;cnstr= &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;server=type in IP address;user=type in database user;password=type in database password;&quot;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;+&lt;/span&gt; &quot;database=type in database &lt;/span&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;name;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Create a new Sql Connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt; cn = &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlConnection&lt;/span&gt;(cnstr);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create the DataSet&lt;/span&gt;&lt;br /&gt;ds = new &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DataSet&lt;/span&gt;(&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;ds&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Create a new Sql Data Adapter&lt;br /&gt;//In your SQL Select statement, only select the columns you want to be displayed&lt;br /&gt;//If you use the select all (*) it will obviously display all the columns&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt; da= &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;SqlDataAdapter&lt;/span&gt;( &lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;&quot;Your Select Statement&quot;&lt;/span&gt; , cn);&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Fill the Data Adapter&lt;br /&gt;&lt;/span&gt;da.Fill(ds);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Set the Datasource for the GridView equal to the DataSet&lt;br /&gt;&lt;/span&gt;GridView1.DataSource = ds;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;//Bind your Data&lt;br /&gt;&lt;/span&gt;GridView1.DataBind();&lt;br /&gt;} &lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;*&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;Quick Note&lt;/span&gt;: Don&#39;t forget to add &#39;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;using&lt;/span&gt; System.Data.SqlClient;&#39; to the top of the code behind page.&lt;/span&gt;&lt;/p&gt;&lt;p  style=&quot;font-family:arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;In your .aspx page add the following code in between the body tags.  &lt;span style=&quot;font-weight: bold;&quot;&gt;Click on the image to view full size &lt;/span&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p face=&quot;arial&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIMWITLCgBie3nrwVAiWmc25Zhx2JzCAYRFhz_xhFZktDIGH_IkM6qZsSwjKtBSZJPakCtGcPJTRIbLP6XHPxoTYvx5ECrWkrDmgGrWcNkLy21eFFMe35BsaK31mhZpJnmX6bc5_DoFwg/s1600-h/gridview.bmp&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIMWITLCgBie3nrwVAiWmc25Zhx2JzCAYRFhz_xhFZktDIGH_IkM6qZsSwjKtBSZJPakCtGcPJTRIbLP6XHPxoTYvx5ECrWkrDmgGrWcNkLy21eFFMe35BsaK31mhZpJnmX6bc5_DoFwg/s400/gridview.bmp&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5179924576547384274&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;font-family: arial;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;If you have any questions or there are discrepancies in the code please feel free to leave a comment and I will try to answer/fix them as soon as I can.&lt;/span&gt;&lt;/p&gt;</description><link>http://just-the-code.blogspot.com/2008/03/dynamically-populating-gridview-with.html</link><author>noreply@blogger.com (vablaza)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIMWITLCgBie3nrwVAiWmc25Zhx2JzCAYRFhz_xhFZktDIGH_IkM6qZsSwjKtBSZJPakCtGcPJTRIbLP6XHPxoTYvx5ECrWkrDmgGrWcNkLy21eFFMe35BsaK31mhZpJnmX6bc5_DoFwg/s72-c/gridview.bmp" height="72" width="72"/><thr:total>3</thr:total></item></channel></rss>