Thursday, March 31, 2016

Gridview: Select deselect all checkboxes in asp.net using Javascript

In this article I am going to tell you how to selecting and deselecting all checkboxes inside Gridview data control using Javascript in asp.net.

How to fill dropdownlist with months name using System.Globalization in asp.net

Description:
When the header checkbox is selected all checkboxes in Gridview got selected and same while uncheck the header checkbox all checkboxes will be unchecked.

Monday, March 28, 2016

ASP.NET: Generate QR code image using Google Chart API

In this article I am going to explain how to generate QR code image using Google Chart API in asp.net.


Description:
QR code image will be generating using Google chart API with a url get request.

Saturday, March 26, 2016

Asp.net: populate dropdownlist with months name

In this article I am going to explain how to populate dropdownlist with months name in asp.net using C# and vb.net.
Description:
System.Globalization namespace contains classes that define culture-related information, including language, country/region, calendars in use, and format patterns for dates, currency, and numbers, and sort order for strings.

Implementation:
HTML Markup:
  <fieldset style="width:50%">
    <legend>Populate Dropdownlist with Months Names</legend>
    Select Country:<asp:DropDownList ID="ddlmonth" runat="server" AutoPostBack="true">
    <asp:ListItem Value="0">--Select--</asp:ListItem>
    </asp:DropDownList>
    </fieldset>

First of all import the namespace

Thursday, March 24, 2016

Get all countries from System.Globalization namespace and fill dropdown in asp.net

In this article I am going to explain how to get all countries list using system.globalization and bind to dropdownlist in asp.net using C# and vb.net.


Description:
System.Globalization namespace contains classes that define culture-related information, including language, country/region, calendars in use, and format patterns for dates, currency, and numbers, and sort order for strings.

Monday, March 21, 2016

ASP.NET: Get and bind all countries to Dropdownlist using Globalization

In this article I am going to explain how to get all countries list using system.globalization and bind to dropdownlist in asp.net using C# and vb.net.


Description:
System.Globalization namespace contains classes that define culture-related information, including language, country/region, calendars in use, and format patterns for dates, currency, and numbers, and sort order for strings.

Sunday, March 20, 2016

Asp.net: How to print a web form (webpage)

In this tutorial I am going to explain how to print a web form (webpage) in asp.net using C# and VB.net
  

Implementation:
Method 1:
<asp:Button ID="btnprint" runat="server" Text="Print" OnClientClick="javascript:window.print()"/>

Method 2:
On button click right the below given code:

Thursday, March 17, 2016

Generate and display QR code image using QR Code library in asp.net

Monday, March 14, 2016

Sql Server: Get number of days between two dates

In this article I am going to explain how to get number of days between two dates in Sql server.



Implementation:

DATEDIFF() function of Sql server returns the number of days between two dates.

Sunday, March 6, 2016

Filter the record using Alphabets pager in asp.net

In this tutorial I am going to explain how to filter the record using Alphabets pager in asp.net


Filter the record using Alphabets pager in asp.net

Description:
To implement this functionality I am using datalist control (alphabets pager) and gridview control (to show the record).

Implementation:
I have created table Tb_Movie and dummy data.
Id
int
Name
varchar(50)
Genre
varchar(50)
Budget
int

Create a store to get data from database:

Saturday, March 5, 2016

Bind comma separated values to listbox in asp.net

In this article I am going to explain how to Bind comma separated values to listbox in asp.net in ASP.Net using C# and VB.net


Implementation:
I have created a table Tb_Technology:
Id
int
Technology
varchar(50)

Insert the dummy data into table:

Asp.net: Get comma separated values from database and bind to checkboxlist

In this article I am going to explain how to get comma separated values (data) from database and bind to checkboxlist in ASP.Net using C# and VB.net

Implementation:
I have created a table Tb_Technology:
Id
int
Technology
varchar(50)

Insert the dummy data into table:

Insert into Tb_Technology(Technology) values('Asp.net,Php,Java')

Add a webform to project. Drag and drop the require control (checkboxlist) from toolbox to webform.

Friday, March 4, 2016

ASP.Net: Insert multiple selected items of listbox to database as comma separated

In this article I am going to explain how to insert multiple selected items of Listbox to database as comma separated in ASP.Net using C# and VB.net
Implementation:

HTML Markup:
<fieldset style="margin-left: 40px;width:30%">
    <legend><strong>Multiple selected values of ListBox</strong></legend>
    <table>
    <tr><td>Select Technology :</td><td>  <asp:ListBox ID="lstboxtech" runat="server" SelectionMode="Multiple">
        <asp:ListItem>Asp.net</asp:ListItem>
         <asp:ListItem>Php</asp:ListItem>
          <asp:ListItem>Java</asp:ListItem>
        </asp:ListBox></td></tr>
    <tr><td></td><td> <asp:Button ID="btnsubmit" runat="server" Text="Submit" /></td></tr>
    </table>
    </fieldset>  

Add the namespace
C# code:
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

VB.net code
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration

Create sqlconnection
C# code:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ToString());

VB.net code
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("connection").ToString())

On button click write the given code
C# code:

protected void btnsubmit_Click(object sender, EventArgs e)
    {
        try
        {
            SqlCommand cmd = new SqlCommand("Insert into Tb_Technology(Technology) values(@technology)", con);
            String str = "";
            for (int i = 0; i <= lstboxtech.Items.Count - 1; i++)
            {
                if (lstboxtech.Items[i].Selected)
                {
                    if (str == "")
                    {
                        str = lstboxtech.Items[i].Text;
                    }
                    else
                    {
                        str += "," + lstboxtech.Items[i].Text;
                    }
                }
            }
            cmd.Parameters.AddWithValue("@technology", str);
            con.Open();
            cmd.ExecuteNonQuery();
            Response.Write("<script>alert('Record Insert SUccessfully');</script>");
            lstboxtech.SelectedIndex = -1;
        }
        catch (Exception ex)
        { }
    }

VB.net code
    Protected Sub btnsubmit_Click(sender As Object, e As System.EventArgs) Handles btnsubmit.Click
       Try
            Dim cmd As New SqlCommand("Insert into Tb_Technology(Technology) values(@technology)", con)
            Dim str As [String] = ""
            For i As Integer = 0 To lstboxtech.Items.Count - 1
                If lstboxtech.Items(i).Selected Then
                    If str = "" Then
                        str = lstboxtech.Items(i).Text
                    Else
                        str += "," + lstboxtech.Items(i).Text
                    End If
                End If
            Next
            cmd.Parameters.AddWithValue("@technology", str)
            con.Open()
            cmd.ExecuteNonQuery()
            Response.Write("<script>alert('Record Insert SUccessfully');</script>")
            lstboxtech.SelectedIndex = -1
        Catch ex As Exception
        End Try
    End Sub



Thursday, March 3, 2016

Insert multiple selected values of checkboxlist to database as comma separated in ASP.Net