Archive for October, 2012

ASP.NET with MySql

October 31, 2012 Leave a comment

Here are the steps to connect your ASP.NET application with MySql Database.

At first, you have to download MySql.Data connector dll from .

Reference the MySql.Data.dll in to your application.

The connection string format will look like this

string conStr = “Server=yourmysqlserver;Port=3309;database=yourdatabasename;userid=username;


Sample code follows

using MySql.Data.MySqlClient;

MySqlConnection sqlConn;
MySqlCommand comm;
//    MySqlDataReader reader;

sqlConn = new MySqlConnection(conStr);

comm = sqlConn.CreateCommand();
comm.CommandText = “UPDATE mytable SET name=’Rami’ WHERE id=1”;




Categories: ASP.NET Tags: , ,

Set Scroll to Top DataGrid or ListView in WPF

October 31, 2012 Leave a comment

You can set the scroll of DataGrid or ListView to top programmatically. Here is the code

  ScrollViewer scrollViewer = GetScrollViewer(gridViewName) as ScrollViewer;

public static DependencyObject GetScrollViewer(DependencyObject o)
if (o is ScrollViewer)
{ return o; }

for (int i = 0; i < VisualTreeHelper.GetChildrenCount(o); i++)
var child = VisualTreeHelper.GetChild(o, i);

var result = GetScrollViewer(child);
if (result == null)
return result;

return null;

Happy coding

Categories: WPF

DatePicker in WPF .NET 3.5

October 11, 2012 Leave a comment

There is no datepicker control in WPF  .NET 3.5 by default.

We can get this by using WPF Toolkit.

You can download WPF toolkit that contains datepicker from

Make a new tab in toolbox

Right Click the tab and select Choose Items

Go WPF Components tab and Click Browse

Go to Tool Kit Installed directory probably C:\Program Files\WPF Toolkit\v3.5.40128.1\

Choose the WPFToolkit.dll and click open.

Click OK.

Now you can see the new tab is populates with some new controls

Now you can drag and drop the datepicker in your page


Happy coding 🙂

Categories: WPF Tags:

Set an Icon for WPF Application

October 4, 2012 Leave a comment

You can set an Icon for your WPF application. First you have to create 24 x 24 .ico file and put inside the application root directory.

Best software to create and manipulate icon file is IconXP. you can download from here try it free(1 month).

To set an icon for WPF window, see the xaml shown below.

<Window x:Class=”MyApp.MainWindow”
Title=”MainWindow” Height=”300″ Width=”350″ Icon=”icon.ico”>




Categories: WPF Tags:

Accordion Control in WPF

October 3, 2012 Leave a comment

Basically there is no Accordion control in WPF. You have to use a 3rd party tool or you have to make it by yourself using StackPanel and Expander controls. I found a nice Accordion Demo here

thank you Liang.Rui for this effort.

His article (in chinese)



Categories: WPF Tags:

How to copy a List SharePoint 2010

October 1, 2012 Leave a comment

You can save  a List as Template to Copy its structure and content to a New List.

To do this, follow these steps

1.Select the List and Click List Settings in the List Tab.

2. Click “Save list as template” under the section “Permission and Management”

3. Enter the file name and template name. Click check box “Include Content” if you want to include both Structure and content.

4.  Click Ok.

5. To make the new list copy. Go Site Actions -> More Options, you can see the created list template under Custom List

6. Click it,  name the new list and click Create

You just created a new copy of a List using its Template. 🙂