Tuesday, July 27, 2010

stuff function

STUFF (SQL Server Compact Edition)

Deletes a specified length of characters and inserts another set of characters at a specified starting point.

Syntax


STUFF ( character_expression, start, length, character_expression )

ROW_NUMBER :

Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition.

Syntax


ROW_NUMBER ()     OVER ( [  ]  )

Friday, July 23, 2010

Dynamic menu control....

In aspx page:

Take asp:menu control....And add bellow code in code behind...

Code behind:

private void loadCategory()
{
DataTable category = new DataTable();

category = CategoryService.Gettopcategory();

DataTable subcat = new DataTable();
subcat = CategoryService.Getsubcategory();

DataView categoryView = new DataView(category);
DataView childCategoryView = new DataView(subcat);



if (categoryView.Count > 0)
{
foreach (DataRowView categoryRowView in categoryView)
{
MenuItem parentMenu = new MenuItem();
parentMenu.Text = categoryRowView["maincategory"].ToString();
parentMenu.Value = categoryRowView["categoryid"].ToString();

childCategoryView.RowFilter = "categoryid=" + (int)categoryRowView["categoryid"];


foreach (DataRowView childcategoryRow in childCategoryView)
{

MenuItem childMenu = new MenuItem();
childMenu.Text = childcategoryRow["subcategory"].ToString();
childMenu.Value = childcategoryRow["subid"].ToString();
//childMenu.NavigateUrl = "~/Default.aspx?CategoryID=" + childMenu.Value;
parentMenu.ChildItems.Add(childMenu);
//}
}
Menu2.Items.Add(parentMenu);
}

}


}