.Net Links

Wednesday, October 28, 2009

SQLExpress database file auto-creation error-SQL Network Interfaces, error: 26

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

SQLExpress database file auto-creation error:


The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:


If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
Sql Server Express must be installed on the machine.

Solution: Add the below lines in your web.config file
connectionStrings
clear/>
add name="LocalSQLServer" connectionString="Server=.;Database=aspnetdb;trusted_connection=yes"
connectionStrings

Labels: , , ,

Thursday, October 22, 2009

Event that is triggered when New is clicked in the Devexpress grid view

The below piece of code enables us to initialize added rows.

ASPxGridView grid= new ASPxGridView();
grid.InitNewRow += new DevExpress.Web.Data.ASPxDataInitNewRowEventHandler(grid_RowInserting);

You can then Call the grid_RowInserting ..So on clicking on the New Link in the Grid, the control is passed on to this function.

Here i have tried to make the columns 2,3 as readonly and column 6 visibility as false

void grid_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
{


((GridViewDataColumn)grid.Columns[2]).ReadOnly = true;
((GridViewDataColumn) grid.Columns[3]).ReadOnly = true;
((GridViewDataColumn) grid.Columns[6]).EditFormSettings.Visible = DevExpress.Web.ASPxClasses.DefaultBoolean.False;

}

Labels: , , , , , ,

Tuesday, October 20, 2009

How to cancell IRCTC trainticket online in case of not travelled / Missed

1.Login to IRCTC
2.Under General Tab Click on File TDR Procedure

Labels: , , ,

Creating a ComboBox Column in DevExpress Grid and Populating it

Craeting a simple ComboBoxColumn in a grid and populating the combo box from Jan..Dec...

{
GridViewDataComboBoxColumn gridCbxMonth = new GridViewDataComboBoxColumn();
gridCbxMonth.Caption = "Month";
gridCbxMonth.FieldName = "Month";
gridCbxMonth.PropertiesComboBox.DropDownStyle = DropDownStyle.DropDown;
gridCbxMonth.PropertiesComboBox.Width = Unit.Pixel(90);
PopulateMonth(gridCbxMonth);
grid.Columns.Add(gridCbxMonth);
}
private void PopulateMonth(GridViewDataComboBoxColumn Month)
{
DateTime dt = new DateTime();

Month.Items.Add("ALL");
for (int i = 0; i < 12; i++)
{
Month.Items.Add(dt.AddMonths(i).ToString("MMMM"));
}
Month.SelectedIndex = 0;
}

Labels: , , , , , , ,

Creating DevExpress Pop-UP Control in two Ways

Below is the code for creating simple Pop-Up Control in two ways using Code Behind.

Method1 Uses ASPxPopupControl.Controls collection :the default popup window will be used

Method 2 : User Created POp-UP window.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


using DevExpress.Web;
using DevExpress.Utils;
using DevExpress.Web.ASPxCallbackPanel;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.ASPxPopupControl;


namespace WebApplication1
{
public partial class Grid_popUp : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{

Method1();
Method2();

}

private void Method1()
{
ASPxPopupControl popupCtrl;
ASPxButton btnClick = new ASPxButton();

btnClick.ID = "btnID1";
btnClick.Text = "Pup-Up-1";
btnClick.AutoPostBack = false;

ASPxLabel lblShowUser = new ASPxLabel();
lblShowUser.Text = "Inside PopUP";

ASPxButton btn = new ASPxButton();
btn.Text = "Inside PopUP";

popupCtrl = new ASPxPopupControl();
popupCtrl.ID = "popupID1";
popupCtrl.ClientInstanceName = "popup";
popupCtrl.PopupElementID = "btnID1";

PopUpSettings(popupCtrl);


form1.Controls.Add(btnClick);
popupCtrl.Controls.Add(GetControl());
form1.Controls.Add(popupCtrl);
}

private void PopUpSettings(ASPxPopupControl popupCtrl)
{
popupCtrl.HeaderText = "My Header";
popupCtrl.Height = Unit.Pixel(300);
popupCtrl.Width = Unit.Pixel(100);
popupCtrl.CssFilePath = "~/_themes/Aqua/{0}/styles.css";
popupCtrl.CssPostfix = "Aqua";
popupCtrl.Left = 400;
popupCtrl.Top = 600;
popupCtrl.PopupAction = DevExpress.Web.ASPxClasses.PopupAction.LeftMouseClick;
popupCtrl.CloseAction = DevExpress.Web.ASPxClasses.CloseAction.CloseButton;
popupCtrl.PopupHorizontalAlign = DevExpress.Web.ASPxClasses.PopupHorizontalAlign.Center;
popupCtrl.PopupVerticalAlign = DevExpress.Web.ASPxClasses.PopupVerticalAlign.Middle;
}

private void Method2()
{
ASPxPopupControl popupCtrl;
ASPxButton btnClick = new ASPxButton();

btnClick.ID = "btnID2";
btnClick.Text = "Pup-Up-2";
btnClick.AutoPostBack = false;

ASPxLabel lblShowUser = new ASPxLabel();
lblShowUser.Text = "Inside PopUP";
PopupWindow pw = new PopupWindow();
pw.Controls.Add(lblShowUser);

popupCtrl = new ASPxPopupControl();
popupCtrl.ClientInstanceName = "popup";
popupCtrl.ID = "popupID2";

PopUpSettings(popupCtrl);


popupCtrl.Windows.Add(pw);
popupCtrl.Windows[0].PopupElementID = "btnID2";

form1.Controls.Add(btnClick);
form1.Controls.Add(popupCtrl);
}
Control GetControl()
{
TextBox txt = new TextBox();
txt.ID = "txt";
txt.Width = 200;
txt.Text = "Dynamic control";

return txt;
}

}
}

Labels:

Tuesday, October 6, 2009

Display Year in the combo box

The following code will display year in the following manner

Current year - 10
Current year - 9
..............
Current year
Current year + 1


int year = DateTime.Now.Year;

for (int i = year - 10; i <= year + 1; i++)
{

cbxYear.Items.Add("" + i);

}

Labels: ,

Display Months in Combo box

The following code will display Month Name from Jan ...Dec in the combo box.

DateTime dt = new DateTime();

for (int i = 0; i < 12; i++)
{
cbxMonth.Items.Add(dt.AddMonths(i).ToString("MMMM"));
}

Labels: , , ,