Archive for Gennaio 18th, 2008

Another way to add first item to ddl

CodeKeep C# Feed Gennaio 18th, 2008

Description: Another way to add first item to ddl

Link: http://www.codekeep.net/snippets/3fa712cb-287e-4f0a-9f24-8a9ab4440db7.aspx

//using RequiredValidator to prompt user if "select a item" is selected
    private void BindDDL1()
    {
        ArrayList ar = new ArrayList();
        ar.Add("jim");
        ar.Add("jen");
        ar.Add("june");
        ar.Insert(0, "please select a name");//"please select a name" will be used in the "InitialValue" to prompt the user that he cant select this "initial value"
        ddl1.DataSource = ar;
        ddl1.DataBind();
    }

Another way to add first item to ddl

CodeKeep C# Feed Gennaio 18th, 2008

Description: Another way to add first item to ddl

Link: http://www.codekeep.net/snippets/3fa712cb-287e-4f0a-9f24-8a9ab4440db7.aspx

//using RequiredValidator to prompt user if "select a item" is selected
    private void BindDDL1()
    {
        ArrayList ar = new ArrayList();
        ar.Add("jim");
        ar.Add("jen");
        ar.Add("june");
        ar.Insert(0, "please select a name");//"please select a name" will be used in the "InitialValue" to prompt the user that he cant select this "initial value"
        ddl1.DataSource = ar;
        ddl1.DataBind();
    }

Another way to add first item to ddl

CodeKeep C# Feed Gennaio 18th, 2008

Description: Another way to add first item to ddl

Link: http://www.codekeep.net/snippets/3fa712cb-287e-4f0a-9f24-8a9ab4440db7.aspx

//using RequiredValidator to prompt user if "select a item" is selected
    private void BindDDL1()
    {
        ArrayList ar = new ArrayList();
        ar.Add("jim");
        ar.Add("jen");
        ar.Add("june");
        ar.Insert(0, "please select a name");//"please select a name" will be used in the "InitialValue" to prompt the user that he cant select this "initial value"
        ddl1.DataSource = ar;
        ddl1.DataBind();
    }

Add first item to dropdownlist

CodeKeep C# Feed Gennaio 18th, 2008

Description: Add first item to dropdownlist

Link: http://www.codekeep.net/snippets/a636b2ec-985a-4363-8307-8d586ffe80b0.aspx

//using if(ddl2.SelectedIndex==0) which is the first item called "please select a item" to prompt user that he cant select this value
    private void BindDDL2()
    {
        DataSet ds = Videos.GetVidInfoByUserName("jim");
        Videos.CloseConn();
        //ds.Tables[0].Rows[0]["imagefilename"] = "Please select a image filename";
        ddl2.DataSource = ds;
        ddl2.DataTextField = "imagefilename";
        ddl2.DataValueField = "id";
        ddl2.DataBind();
       
    }

Get current DateTime in C#

CodeKeep C# Feed Gennaio 18th, 2008

Description: Get current DateTime in C#

Link: http://www.codekeep.net/snippets/2afc4e00-b358-431a-8626-7c3dd1085e6e.aspx

DateTime variablename = System.DateTime.Now;

Get current DateTime in C#

CodeKeep C# Feed Gennaio 18th, 2008

Description: Get current DateTime in C#

Link: http://www.codekeep.net/snippets/2afc4e00-b358-431a-8626-7c3dd1085e6e.aspx

DateTime variablename = System.DateTime.Now;