Geeks With Blogs

News

Microsoft MVP


Moderator at CodeASP.NET


Quiz Master




free counters
Free counters
Added on January 19,2012


Follow Me @vmsdurano

A bit About Me



Disclaimer
The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.


Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer" ADO.NET There are 43 entries for the tag ADO.NET
Product Review - ComponentOne Studio for MVC Wijmo
Wijmo is an awesome tool from ComponentOne. The goal of this tool is to help us web developers rapidly develop MVC applications with interfaces richer than WebForms. Main Features: 1.Over 30 UI Widgets with everything from interactive menus to rich charts. 2.MVC scaffolding automation. This means that Wijmo generates rich interactive Views and Controllers for your entire Model. Free Trial DownLoad: http://www.componentone.com... In this review we'll take a look at Wijmo ......

Posted On Monday, August 22, 2011 6:08 PM

ASP.NET MVC 3: Creating a Simple Sign-Up Form
In this article I'm going to demonstrate how to create a simple sign-up form using ASP.NET MVC 3. So basically in this demo you will learn the following: How to insert data to the database with Entity Framework How to validate the Form using Data Annotations How to Authenticate users after sign up using FormsAuthentication Note that before you continue reading this article be sure that you have the basic understanding about ASP.NET MVC in general. You can refer the following links below to learn ......

Posted On Friday, June 3, 2011 8:44 PM

Entity Framework - Inserting Data to Database
Few months ago I wrote a series of articles regarding how to Insert, Update, Fetch and Delete data in the form using LINQ to SQL. You can view the series of articles below: Inserting Data to Database using LINQ to SQL Fetching Data from Database and Populating fields in the Form using LINQ to SQL Editing, Updating and Deleting Data in the Form using LINQ to SQL In this article I'm going to demonstrate the basics on how to work with MS Entity Framework. Basically in this part I'm going to show you ......

Posted On Monday, April 4, 2011 11:59 AM

Dynamically Adding TextBox Control to ASPNET Table: Part 2
Few months ago I wrote an example about Dynamically Adding TextBox Control to ASPNET Table. As a recap that example demonstrate how to generate rows of TextBoxes in a Table control based on the number of rows and number of columns provided and as well as print the values entered by the user using the Request.Forms collections.. Recently,one of the user is asking if how are we going to accomplish the same thing by generating the TextBox in the Table based on the data from the database. So in this ......

Posted On Tuesday, January 25, 2011 5:24 PM

Uploading and Importing CSV file to SQL Server in ASP.NET WebForms
Few weeks ago I was working with a small internal project that involves importing CSV file to Sql Server database and thought I'd share the simple implementation that I did on the project. In this post I will demonstrate how to upload and import CSV file to SQL Server database. As some may have already know, importing CSV file to SQL Server is easy and simple but difficulties arise when the CSV file contains, many columns with different data types. Basically, the provider cannot differentiate data ......

Posted On Monday, January 3, 2011 5:03 PM

FAQ: GridView Calculation with JavaScript - Formatting and Validation
In my previous post here we've talked about how to calculate the sub-totals and grand total in GridView using JavaScript. In this post I'm going take more step further and will demonstrate how are we going to format the totals into a currency and how to validate the input that would only allow you to enter a whole number in the quantity TextBox. Here are the code blocks below: ASPX Source: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml... ......

Posted On Thursday, December 9, 2010 5:17 PM

Inserting Data to Database using LINQ to SQL
Few months ago, I’ve created a simple demo about “Creating a Simple Registration Form using the ADO.NET way”. In this article, I'm going to demonstrate how to create a simple form that would allows users to insert data to the database using L2S. As an overview, LINQ to SQL is a technology that allow you to query sql server. LINQ to SQL is an O/RM (object relational mapping) implementation that ships in the .NET Framework "Orcas" release, and which allows you to model a relational database using .NET ......

Posted On Thursday, March 11, 2010 3:12 PM

Move Multiple Rows Between GridViews
This example shows how to move multiple rows between GridViews. The main idea here is to use a CheckBox control for selecting the rows to be removed from one GridView to another and vise versa. Take a look at sample screen shots below: On initial load: Selecting rows from the left GridView: After Moving the selected rows to the right GridView: As you notice the selected rows are automatically sorted by its ID upon moving. Selecting rows from the Right GridView: After Moving the selected rows to the ......

Posted On Thursday, October 8, 2009 11:19 PM

How To: Prevent SQL Injection in ASP.NET
Mike Brind has written a very good example about "Preventing SQL Injection in ASP.NET". If you are new to Data Access manipulations in ASP.NET then I would strongly suggest you to read the article mentioned above. Technorati Tags: ADO.NET,ASP.NET,General ......

Posted On Wednesday, August 26, 2009 7:16 PM

Bind DataTable to DataList Control
This example shows how to bind a DataTable in a DataList control. Just for the simplicity of this demo I’m going to create a dummy data in the DataTable. See the code blocks below: private DataTable GetData() { DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new System.Data.DataColumn("Col... typeof(String))); dt.Columns.Add(new System.Data.DataColumn("Col... typeof(String))); dt.Columns.Add(new System.Data.DataColumn("Col... typeof(String))); dr = dt.NewRow(); dr[0] = "Column1 ......

Posted On Thursday, August 13, 2009 10:41 PM

Removing Columns in DataTable
Recently, one of the members in the forum (http://forums.asp.net) is asking if how to remove a particular column in a DataTable if all values in the row of that column are null or empty. So I decided to post the solution that I have provided in that thread as a reference to others who encounter the same problem. Just for the simplicity of this demo, I created a sample DataTable with a dummy data on it just for us to test. Here’s the code block below: private DataTable CreateDataTable() { DataTable ......

Posted On Tuesday, August 11, 2009 8:32 PM

Why DataSet creates TableN as the Default Table name?
Few days ago I have encountered a question in asp.net forums asking if why does the DataSet creates a default name as Table1 well in fact the name doesn’t really exist in the database. So I thought I’d share the answer that I have provided in that thread as a reference to others. As the documentation states that: "Multiple Result Sets: If the DataAdapter encounters multiple result sets, it will create multiple tables in the DataSet. The tables will be given an incremental default name of TableN, ......

Posted On Monday, August 3, 2009 5:15 PM

Uploading and Storing Image Path to Database and Image to Folder - Part 2 (Displaying of Images)
In my previous example, we have learned on how to save the actual image to a folder and image path to the database. In this example, I’m going to show on how to display those images in a GridView and Repeater control. To get started, let’s create a method for fetching the image information from the database. Here’s the code block below: private DataTable GetData() { DataTable dt = new DataTable(); SqlConnection connection = new SqlConnection(GetConnection... try { connection.Open(); string ......

Posted On Sunday, August 2, 2009 5:55 PM

Uploading and Storing Image Path to Database and Image to Folder - Part 1
I decided to write this example because this has been asked many times at the forums. In my previous article I have shown on how to Upload and Save the Images to Database, In this article I will show on how to upload and save the image to folder and path to database. To get started, let’s create a simple database table for storing the Image information and path to the database. I this example I named the table as “ImageInfo” with the following fields below: Note:I set the Id to auto increment so ......

Posted On Sunday, August 2, 2009 4:58 PM

Save Dynamic TextBox Values from GridView to Database
In my previous article, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes. Now, seems that most of the developers are asking if how to save all the data that was entered from the dynamic textbox in the GridView to the database. So in this example, I’m going to show on how to save them all in the database. To get started then lets create a sample Table in SQL Server. In this example, I named the table as “SampleTable” with the following fields below: Note: I set the ......

Posted On Sunday, August 2, 2009 1:54 PM

Sorting GridView Manually with TemplateFields
I decided to write this example because this has been asked many times at the forums. In this article, I will show on how to sort GridView columns manually using a DataTable. Note that in this example, I used my own database for populating the GridView. See Adding Rows in GridView for more info. Now to get started lets set up the GridView with TemplateField columns. Since we are working with TemplateFields then we need to handle sorting manually by adding a LinkButton control inside the HeaderTemplate ......

Posted On Sunday, July 12, 2009 4:58 PM

Adding Rows in GridView with Edit, Update and Delete Functionality
This example is a continuation of my previous post about “Adding Rows in GridView”. In this example I will going to demonstrate on how we are going to do Edit, Update and Delete operations in GridView using TemplateField Columns. If you wan’t to implement those operations using BoundField Columns then you can refer to my previous example about “GridView: Insert, Edit, Update and Delete – the ADO.NET way”. Since this example is a continuation, then I would recommend you to start reading this example ......

Posted On Wednesday, June 10, 2009 2:28 AM

Adding Rows in GridView
This example shows on how to add rows of data in the GridView control. In this example, I created a simple database table called “Table1” for storing the data. The Table has the following columns: Id – PK Employees Position Team Note that I added some dummy data in table that I have created so that we can display something in the GridView when the page is loaded for the first time. To get started, let’s grab a GridView Control from the Visual Studio ToolBox and place it in the webform. Then set up ......

Posted On Tuesday, June 9, 2009 10:37 PM

Move AutoGenerate Columns at LeftMost Part of the GridView Columns
There are certain scenarios that we need to combine an AutoGenerated Columns with TemplateField Columns or even BoundField Columns in the GridView. As we all know, by default the GridView will automatically display all the AutoGenerated Columns to the rightmost column of the GridView. Consider this example below: Assuming that we have this GridView markup below: <asp:GridView ID="GridView1" runat="server"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Button ID="Button1" ......

Posted On Wednesday, June 3, 2009 10:23 PM

Pre-Select Multiple ListBox items based on Database Value
I decided to write a simple demo about this because I always encounter this issue at the forums. Basically, this demo shows how to pre select multiple list items in the ListBox control based from database value. Assuming that we have this table definition with data below: As you can see, the Table has a "IsSelected" boolean field which indicates that a particular employee name is selected or not. Note that in this demo, I named the Table above as "Table1". Now lets set up our ListBox at the ASPX ......

Posted On Monday, June 1, 2009 1:45 PM

FAQ: Calculate Totals in GridView and Display it in Footer - Server side approach
I decided to write this post because I always encounter this kind of issue so many times before at the forums. The main question is that they want to automatically calculate the totals when a user enter an amount from the TextBox control that is residing in the GridView template. So this example shows the basic way on how to achieve this with the server side manipulations. Note that this demo requires that you know the basics of ADO.NET and for binding a GridView control with data from database. ......

Posted On Monday, June 1, 2009 1:20 PM

ListBox Control: Save Multiple Selected Items in the Database
This example shows the basics on how to save multiple selected items from the ListBox control to the database. Please note that this example requires a basic knowledge of ADO.NET. STEP 1: Setting up the User Interface (GUI) For the simplicity of this demo, I just set up the web form like below: <html xmlns="http://www.w3.org/19... <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> Employee ......

Posted On Sunday, May 31, 2009 7:11 PM

Pivot Data in GridView - A Generic Pivot Method with DataTable
This example shows how to “PIVOT” the original data that is displayed in the GridView. To start then lets grab two GridViews from the Visual Studio Toolbox and place it to your webform. The ASPX source would look something like this: ORIGINAL Table: <asp:GridView ID="GridView1" runat="server"> </asp:GridView><br /><br /> PIVOTED Table: <asp:GridView ID="GridView2" runat="server" ShowHeader="false"> </asp:GridView> Now, lets create the Generic method for Pivoting ......

Posted On Sunday, May 10, 2009 9:04 PM

Filter GridView Data based from Date Ranges
This example shows how to filter data in GridView based from two given dates. For example you have two Calendar Control which is allows you to select the Start Date and End Dates accordingly. These selected dates will then be displayed in TextBoxes and later on you wish to Grab the data from the database based from the dates (StartDate and EndDate) that is displayed in the TextBox and bind the result to a GridView control. Here are the code blocks below: private string GetConnectionString(){ //call ......

Posted On Thursday, May 7, 2009 5:11 PM

Save CheckBoxList Selected Items and Retain them on PostBacks.
I decided to write this example because I always encounter this kind of issues at http://forums.asp.net . This demo basically shows how to save the CheckBoxList selected items in the database and retain its selected items on postbacks or when the page is loaded again. To get started then lets start by creating the database for storing the data. STEP 1: Creating the database. Launch Sql Server Management Studion Express and then connect Expand the Databases folder from the Sql Server object explorer ......

Posted On Wednesday, May 6, 2009 9:15 PM

Creating a Simple Registration Form in ASP.NET
This example shows how to create a very simple registration form in ASP.NET WebForms. STEP1: Creating the Database. The following are the basic steps on how to create a simple database in the Sql Server: Launch Sql Server Management Studion Express and then connect Expand the Databases folder from the Sql Server object explorer Right click on the Databases folder and select “New Database” From the pop up window, input the database name you like and click add Expand the Database folder that you have ......

Posted On Thursday, April 30, 2009 8:09 AM

FAQ: Displaying Image from Database to GridView Control
I wrote this demo because I observed that lots of people in the forum (forums.asp.net) always ask questions on how to display Image that was stored in the database to GridView control. Before reading this example, be sure that you have already know how to upload image to the database. If you are not familiar with it then I would suggest you to read my previous example about “Uploading and Storing Images to Database in ASP.NET”. In this demo, we are going to use a Handler.ashx file for fetching the ......

Posted On Friday, April 24, 2009 8:52 AM

Displaying Image to Image Control based on User Selection in ASP.NET
This example is a continuation of my previous example about “Uploading and Storing Images to Database in ASP.NET”. In this demo, I’m going to show how to display image (binary format) from database to ASP Image control and display its corresponding image information based on user selection. In this demo, we are going to use a Handler.ashx file for fetching the binary data from the database and then stream it. What is a Handler? A handler is responsible for fulfilling requests from a browser. Requests ......

Posted On Friday, April 24, 2009 3:15 AM

Uploading and Storing Images to Database in ASP.NET
This example demonstrates how to upload image using the FileUpload control and store the uploaded file in the database in binary format. STEP 1: Creating the Database. The following are the basic steps on how to create a simple database in the Sql Server: Launch Sql Server Management Studion Express and then connect Expand the Databases folder from the Sql Server object explorer Right click on the Databases folder and select “New Database” From the pop up window, input the database name you like ......

Posted On Thursday, April 23, 2009 11:13 AM

Displaying two Column Fields in DropDownList Control
There are two basic ways on how to display two fields from database in the DropDownList. The first one is concatenating it in the sql query and the second one is concatening it programmatically in codes. Manipulating the sql query to concatenate two fields. Here’s the code block below. private void BindDropDownList() { DataTable dt = new DataTable(); SqlConnection connection = new SqlConnection(GetConnection... try { connection.Open(); string sqlStatement = "SELECT CustomerID + ' ---- ' + ......

Posted On Wednesday, March 11, 2009 4:15 PM

Tip/Trick: Show Header and Footer of GridView when no Data returned.
This example demonstrates how to show the Header and Footer of GridView when no data returned from the DataSet or DataTable. The trick here is to add a new blank row to the DataTable that you used as your DataSource if there was no data returned in your query. Here’s the method for showing the Header and Footer of GridView when no data returned in the query. private void ShowNoResultFound(DataTable source, GridView gv) { source.Rows.Add(source.NewR... // create a new blank row to the DataTable ......

Posted On Wednesday, March 11, 2009 4:10 PM

Creating a Simple ShoutBox with MultiLine TextBox
Overview This demo explains how to create a simple ShoutBox using the ASP.NET MultiLine TextBox. A “ShoutBox” basically allow end users to post commentsin the page. To begin let’s create a WebUserControl and implement our ShoutBox there. Why UserControl? We used WebUserControl so that we can re-use and place the control anywhere in your page by simply dragging it to the WebForm. Step 1: Creating the Database In this demo, I presumed that you already have a basic background on how to create a simple ......

Posted On Tuesday, February 24, 2009 5:50 PM

Moving ListItems between Two ListBox – Server Side Approach
This example shows how to move items between two ListBox. Basically it allows you to add, remove and move multiple list items at a time. To start, let’s set up our GUI. Just for simplicity of this demo, I set up the web form like this: 1: <head runat="server"> 2: <title>Moving ListItems between two ListBox</title> 3: </head> 4: <body> 5: <form id="form1" runat="server"> 6: <div> 7: <table> 8: <tr> 9: <td ><asp:ListBox ID="ListBox1" runat="server" ......

Posted On Tuesday, February 24, 2009 5:41 PM

Binding DropDownList, ListBox and CheckBoxList Control the ADO.NET way.
This example shows how to bind DropDownList, ListBox and CheckBoxList control with data from database using the ADO.NET way. Note that in this demo, I’m using the Northwind database. Now let’s set up the connection string. STEP 1: Setting up the Connection string In your web.config file set up the connection string there as shown below: <connectionStrings> <add name="DBConnection" connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirec... Integrated Security=True;User ......

Posted On Tuesday, February 24, 2009 5:31 PM

GridView Multiple Delete with CheckBox and Confirm
This demo describes how to implement multiple delete in GridView using CheckBox control and display a confirmation message upon deletion. Assuming that we have this GridView column mark up below <Columns> <asp:TemplateField> <HeaderTemplate> <asp:Button ID="ButtonDelete" runat="server" Text="Delete" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="CustomerID" ......

Posted On Sunday, February 22, 2009 2:01 AM

Display Confirmation Message on GridView Deleting
This demo describes the different approach to display a confirmation message when deleting a row in GridView and pass the id of the item to the confirmation message. Confirmation means a user is asked first if he/she wanted to delete a record by choosing an option (OK and CANCEL). In this demo, we use the JavaScript confirm function for displaying the confirmation message. Now let’s create our JavaScript confirm function. To do this switch to ASPX source and add the following code block within the ......

Posted On Sunday, February 22, 2009 1:52 AM

GridView Insert, Edit, Update and Delete – The Ado.Net way
This demo is a continuation of my previous example “Binding GridView with Data”. If you are not familiar of binding the GridView the ado.net way then I would suggest looking at my previous example first before you proceed to this example. Basically, this demo describes the basic way to do INSERT, EDIT, UPDATE and DELETE data in ASPNET GridView Control using the ADO.NET way. STEP 1: Creating a DataBase Table In this demo, I presumed that you already have a basic background on how to create a simple ......

Posted On Sunday, February 22, 2009 1:34 AM

Binding GridView with Data - The ADO.NET way
This example demonstrates how to populate GridView with data from the database using the ADO.NET way. Before you proceed reading this example be sure that you know the basics of ADO.NET manipulation. If you are not familiar with ADO.NET then I would suggest you to refer at the following link below: ADO.NET Tutorial STEP 1: Setting up the Connection String - Open your Web.config file and set up your connection string like below: <connectionStrings> <add name="MyDBConnection" connectionString="Data ......

Posted On Thursday, February 19, 2009 9:35 PM

Custom Login: Validating UserName and Password using the ADO.NET way
The snippet below describes on how we are going to validate the user credentials being supplied by the end user in Login page using the ADO.NET way.. C# protected void ValidateUserInfo(string user, string pass) { SqlConnection connection = new SqlConnection("YOUR CONNECTION STRING HERE"); string sql = "SELECT * FROM TableName WHERE UserID = @username AND Password = @password"; SqlCommand cmd = new SqlCommand(sql,connection); cmd.Parameters.AddWithValue... user); cmd.Parameters.AddWithValue... ......

Posted On Friday, September 12, 2008 1:26 AM

Bind TextBox and Label Control with Data from database
This sample snippet below describes on how we are going to Populate a TextBox and Label control in the page based on the data associated per user using the ADO.NET way.. C# private void getData(string user) { DataTable dt = new DataTable(); SqlConnection connection = new SqlConnection("YOUR CONNECTION STRING HERE"); connection.Open(); SqlCommand sqlCmd = new SqlCommand("SELECT * from TABLE1 WHERE UserID = @username", connection); SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd); sqlCmd.Parameters.AddWithVa... ......

Posted On Friday, September 12, 2008 1:16 AM

Manually Binding DropDownList based on the value selected on the first DropDownList
I decided to write this sample demo because I always encounter this kind of problem in the ASPNET Forum . So here's a sample (one way) solution on how to populate the second DropDownList based on the value selected on the first DropDownList using the ADO.NET way. Assuming that DropDownList1 contains the list of countries and we need to populate the list of States in a particular country based on the first DropDownList selection. protected void PopulateDropDownList1(){ string queryString = "SELECT ......

Posted On Thursday, September 11, 2008 10:56 AM

Creating Chart with Aspnet ReportViewer control
Introduction This article shows on how to generate a chart (a graphical representation of data) using the aspnet ReportViewer control. Basically, this report is called an rdlc file “Local Mode” which means that a report is generated at the client side and no connection established to the Sql Server Reporting Service Server. In this example, I am creating a report(chart) that would display the stock out movement. The page includes a DropDownList to allow users to filter a specific stock category that ......

Posted On Monday, February 4, 2008 2:04 AM

Creating a Simple Data Access Framework in ASP.NET
Introduction: This article describes on how to create a data access architecture using sqlclient objects that will returns a DataTable. It also discusses here on how to use and access a certain method in a particular class for you to manipulate the data into your codes. Please note that I am using the Northwind database here and all the codes in this article are written in C# language. STEP1: Adding a Class First, I added some folders under my App_Code folder to store some classes. This class includes ......

Posted On Friday, February 1, 2008 9:35 AM

Copyright © Vincent Maverick Durano | Powered by: GeeksWithBlogs.net | Join free