Archive

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 http://dev.mysql.com/downloads/connector/net/1.0.html .

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;

password=passwd”;

Sample code follows

using MySql.Data.MySqlClient;

MySqlConnection sqlConn;
MySqlCommand comm;
//    MySqlDataReader reader;

sqlConn = new MySqlConnection(conStr);
sqlConn.Open();

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

comm.ExecuteNonQuery();

sqlConn.Close();

🙂

Advertisements
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;
scrollViewer.ScrollToHome();

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)
{
continue;
}
else
{
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 http://wpf.codeplex.com/releases/view/22567

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 http://www.aha-soft.com/iconxp/ try it free(1 month).

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

<Window x:Class=”MyApp.MainWindow”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
Title=”MainWindow” Height=”300″ Width=”350″ Icon=”icon.ico”>

..

</Window>

 

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

http://files.cnblogs.com/RMay/AccordianDemo.rar

thank you Liang.Rui for this effort.

His article http://www.cnblogs.com/RMay/archive/2008/08/22/1273927.html (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. 🙂