Wednesday, August 1, 2018

how to create data picker using dropdown list and text box : Sradha WebCreations

how to create data picker using drop down list and text box asp.net , sql server 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class OR_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int i;
        for (i = 1; i <= 31; i++)
        {
            DropDownListDAY.Items.Add(Convert.ToString(i));
        }
        DropDownListMONTH.Items.Add("JAN");
        DropDownListMONTH.Items.Add("FEB");
        DropDownListMONTH.Items.Add("MAR");
        DropDownListMONTH.Items.Add("APR");
        DropDownListMONTH.Items.Add("MAY");
        DropDownListMONTH.Items.Add("JUN");
        DropDownListMONTH.Items.Add("JUL");
        DropDownListMONTH.Items.Add("AUG");
        DropDownListMONTH.Items.Add("SEPT");
        DropDownListMONTH.Items.Add("NOV");
        DropDownListMONTH.Items.Add("DEC");

        int X;
        for (X = 1900; X <= 2000; X++)
        {
            DropDownListYEAR.Items.Add(Convert.ToString(X));
        }
    }

    string sday;
    string sMonth;
    string sYear ;

    protected void ButtonDATE_Click(object sender, EventArgs e)
   
{
        sday = Convert.ToString(DropDownListDAY.SelectedItem.Text);

        sMonth = Convert.ToString(DropDownListMONTH.SelectedItem.Text);

        sYear = Convert.ToString(DropDownListYEAR.SelectedItem.Text);

       // string sDate = sday + "/" + sMonth + "/" + sYear;
        string sDate=DropDownListDAY.SelectedItem.Text+"/"+DropDownListMONTH.SelectedItem.Text+"/"+DropDownListYEAR.SelectedItem.Text;
     
  Convert.ToString( TextBoxDATE.Text=sDate );

    }
}







No comments:

Post a Comment