This demo shows on how to dynamically adding /removing ListItems in the ASP.NET DropDownList control using JavaScript. Here’s the mark up and the JavaScript code block below: <html xmlns="http://www.w3.org/19... <head runat="server"> <title>Dynamic DropDownList</title> <script type="text/javascript" language="javascript"> function AddItemInList() { var list = document.getElementById('Dr... var box = document.getElementById('Te... var newListItem ......
This demo shows how to generate a Table with TextBoxes dynamically based from the number of Columns and Rows entered from the TextBox control and print the values of the dynamically added TextBox on the page. See the screen shot below: To start, let’s declare the following global variables below: private int numOfRows = 0; private int numOfColumns = 0; Here’s the code block for the generating the Tables with TextBoxes. private void GenerateTable(int colsCount, int rowsCount){ //Creat the Table and ......
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 + ' ---- ' + ......
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 ......
This demo shows on how to do multiple date selections in the standard ASP.NET Calendar Control. The basic idea here is we use List collection to hold the selected dates from the calendar control and store them into Session to keep the selected dates on postbacks and assigned the selected dates back based from the list values at SelectionChanged event.. Here's the code blocks below: First we need to declare the following namespace below for us to use the List Class using System.Collections.Generic; ......