d e v d u d e . n e t
Gateman sees name, garageman sees name tag.

Devdude.net
About Me
Photo Gallery One
Photo Gallery Two
Projects
ASP.NET Code
Technology Links
ROBLOG
My Resume
Email Me


ASP.NET Code Samples

Insert/Update/Select items with parameters in MS Access.
  • (stardeveloper) Resizing Images After Uploading
  • (codeproject) Uploading and Resizing Images Convert To PNG
  • (codeproject) Uploading and Resizing Images
  • (codeproject) Uploading and Resizing Images Into A Database
    public static int UpdateArticle(string article_id, string title, string article)
    {
    	string sql	=	"UPDATE article SET title = @title, article = @article " +
    					"WHERE article_id = @article_id";
    	int articleStatus = 0;
    	OleDbConnection conn	= new OleDbConnection(BaseData.DbConnect);
    	OleDbCommand cmd		= new OleDbCommand(sql,conn);
    	conn.Open();
    
    	cmd.Parameters.Add(new OleDbParameter("@title", title));
    	cmd.Parameters.Add(new OleDbParameter("@article", article));
    	cmd.Parameters.Add(new OleDbParameter("@article_id", article_id));
    
    	articleStatus = cmd.ExecuteNonQuery();
    	conn.Close();
    	return articleStatus;
    }
    
    Add An Item To A DropDownList control.
    selectAddType.DataSource		= Schools.GetSchoolTypeList();
    selectAddType.DataTextField		= "type";
    selectAddType.DataValueField	= "school_type_id";
    selectAddType.DataBind();
    selectAddType.Items.Insert(0, new ListItem("Choose A School Type",""));
    
    Select an item in a drop down list.
    // In Code Behind
    ListBox1.SelectedIndex = 2;
    
    //Set the item programatically.
    selectAddColors.Items.FindByValue(Schools.color).Selected = true;
    
    //Set the item from database.
    for(int i = 0; i < chkbListAddGrades.Items.Count; i++)
    {
     if(chkbListAddGrades.Items[i].Value.ToString() == Convert.ToString(Schools.SchoolGrades[i]))
      {
       chkbListAddGrades.Items.FindByValue(Convert.ToString(Schools.SchoolGrades[i])).Selected = true;
      }
    }
    
    
    Popluate drop list with grouped contents.
    		{
    			int schoolId = 0;
    			int schoolName = 1;
    			int schoolType = 2;
    			string currentSchoolType = "";
    			OleDbDataReader SchoolList = Schools.GetSchoolList();
    			ddlSchools.Items.Add(new ListItem("Choose A School",""));
    			while (SchoolList.Read())
    			{
    				if (currentSchoolType != SchoolList.GetValue(schoolType).ToString())
    				{
    					//set/reset school type
    					AddItemToDropList("  ","",ddlSchools);
    					AddItemToDropList(" -- " + SchoolList.GetValue(schoolType).ToString().ToUpper() + " SCHOOLS -- ","",ddlSchools);
    					currentSchoolType = SchoolList.GetValue(schoolType).ToString();
    				}
    				AddItemToDropList(SchoolList.GetValue(schoolName).ToString(),SchoolList.GetValue(schoolId).ToString(),ddlSchools);
    			}
    			ddlSchools.Attributes["OnChange"] = "MoveAlong(this)";
    		}
    
    		private void AddItemToDropList(string dlName, string dlValue, DropDownList objControl)
    		{
    			objControl.Items.Add(new ListItem(dlName,dlValue));
    		}
    

    Article about showing and hiding div tags
    	I think what you want to do is implement the stack of text boxes I
    	outlined above. If so, here's how you might do it (but it is still using
    	javascript, just hidden javascript):
    	

    The following code increments the id of the input-element and shows the id as content of the text-field. It works in MSIE and Mozilla:
    This is box 1. Please fill it in:


  •  << JULY 2010 >> 
    S M T W T F S
            1 2 3
    4 5 6 7 8 9 10
    11 12 13 14 15 16 17
    18 19 20 21 22 23 24
    25 26 27 28 29 30 31