How to display images in datagridview in windows application
private string ImagePath = @"C:\Users\Public\Pictures\Sample Pictures\";
private void bindGrid(){dataGridView1.DataSource = getTable();}private DataTable getTable(){string[] strImage;DataTable dt = null;try{System.Data.SqlClient.SqlConnection con;strImage = System.IO.Directory.GetFiles(ImagePath, "*.jpg");int ImageCount = strImage.Length;dt = new DataTable();dt.Columns.Add("Sno", typeof(int));dt.Columns.Add("Name", typeof(Image));DataRow dr = null;for (int i = 1; i < ImageCount; i++){dr = dt.NewRow();dr[0] = i.ToString();dr[1] = Image.FromFile(strImage[i]);dt.Rows.Add(dr);dr = null;}return dt;}catch (Exception ex){throw ex;}finally{if (dt != null)dt = null;}}
Wednesday, July 1, 2009
Working in ListView Control
ListView control is a new control added into ASP.NET 3.5. It enables you to display data in a format specified by you using templates and styles. It is useful for data in any repeating structure just like DataList and Repeater controls. However, unlike those controls ListView control enable you to edit, insert, delete, sort, paginate data without any extra effort
Step 1stFirst create a new .aspx page and go to design view. Go to Data tab of the Toolbox and drag ListView control to your page. Now again go to the Data tab and drag LinqDataSource control to the page. Now configure the LinqDataSource control as described in Make sure that you have selected Enable Delete, Enable Insert and Enable Update checkbox from the smart tag of the LinqDataSource control as displayed in the picture below
Step 2nd
Now open the smart tag of the ListView control and choose the Data Source as the LinqDataSource as displayed in the picture below.
Step 3rd
Now click on Configure ListView … from the smart tag of the Listview. Select Tiled from Layout, Professional from Style and Enable Editing, Enable Inserting, Enable Deleting and Enable Paging from the Options as displayed in the picture below. In the Enable Paging dropdown you may select Next/Previous pager or Numeric pager
Step 4th
Now Save your files and press F5 to run. You should see an Insert form in your browsers. Just enter few records, try editing, deleting records. Once the number of records will exceed the PageSize of the DataPagers (that will be automatically inserted into ListView when you will select Enable Paging from the Configure ListView dialogue box) First, Previous, Next and Last button at the bottom will be enabled automatically.
Hope you enjoyed playing with ListView and LinqDataSource control. Do let me know if you have any comments or suggestions. Thanks and Happy Coding !!!
Step 1stFirst create a new .aspx page and go to design view. Go to Data tab of the Toolbox and drag ListView control to your page. Now again go to the Data tab and drag LinqDataSource control to the page. Now configure the LinqDataSource control as described in Make sure that you have selected Enable Delete, Enable Insert and Enable Update checkbox from the smart tag of the LinqDataSource control as displayed in the picture below
Step 2nd
Now open the smart tag of the ListView control and choose the Data Source as the LinqDataSource as displayed in the picture below.
Step 3rd
Now click on Configure ListView … from the smart tag of the Listview. Select Tiled from Layout, Professional from Style and Enable Editing, Enable Inserting, Enable Deleting and Enable Paging from the Options as displayed in the picture below. In the Enable Paging dropdown you may select Next/Previous pager or Numeric pager
Step 4th
Now Save your files and press F5 to run. You should see an Insert form in your browsers. Just enter few records, try editing, deleting records. Once the number of records will exceed the PageSize of the DataPagers (that will be automatically inserted into ListView when you will select Enable Paging from the Configure ListView dialogue box) First, Previous, Next and Last button at the bottom will be enabled automatically.
Hope you enjoyed playing with ListView and LinqDataSource control. Do let me know if you have any comments or suggestions. Thanks and Happy Coding !!!
Object Oriented Programming
Object Oriented Programming
An object-oriented programming language (also called an OO language) is one that allows or encourages, to some degree, object-oriented programming techniques such as encapsulation, inheritance, modularity, and polymorphism
An object-oriented programming language (also called an OO language) is one that allows or encourages, to some degree, object-oriented programming techniques such as encapsulation, inheritance, modularity, and polymorphism
Steps of Collection Class
Steps of Collection Classclass Leaf {private int intAge;private String strName;
// Default Constructor public Leaf() {}
// gets and sets the age valuepublic int Age {get {return intAge;}set {intAge = value;}}
// gets and sets the strName variablepublic string Name {get {return strName;}set {strName = value;}}}
// Default Constructor public Leaf() {}
// gets and sets the age valuepublic int Age {get {return intAge;}set {intAge = value;}}
// gets and sets the strName variablepublic string Name {get {return strName;}set {strName = value;}}}
Working in Nic Edit Mask
Working in Nic Edit Mask function mask(str,textbox,loc,delim){var locs = loc.split(',');
for (var i = 0; i <= locs.length; i++){for (var k = 0; k <= str.length; k++){if (k == locs[i]){if (str.substring(k, k+1) != delim){str = str.substring(0,k) + delim + str.substring(k,str.length)}}}}textbox.value = str}
for (var i = 0; i <= locs.length; i++){for (var k = 0; k <= str.length; k++){if (k == locs[i]){if (str.substring(k, k+1) != delim){str = str.substring(0,k) + delim + str.substring(k,str.length)}}}}textbox.value = str}
Subscribe to:
Posts (Atom)