Friday, August 19, 2011

Getting distinct column with multiple columns

if we have table id, name, age


the requirements is id has different and redundatnt data


We want the distinct column with corresponding rows. this is highly useful


SELECT id,
role_id_fk,
privilege_id_fk
FROM (SELECT id,
role_id_fk,
privilege_id_fk,
Row_number() OVER(PARTITION BY role_id_fk ORDER BY id) rn
FROM tbl_roles_privileges) t
WHERE rn = 1

Thursday, July 14, 2011

ASP.NET

how to access the usercontrol's property or method()


SearchUsercontrol is a usercontrol. The requirement is to access a usercontrol’s method or property from the parent aspx page.

For normal aspx pages (with out master pages)

Usercontrol1.Method() or userconrol.GetID

For normal aspx pages (with master page)

SearchUsercontrol _displayResultsUserControl = _contentPlaceHolder.FindControl("SearchResults") as SearchUsercontrol;

_displayResultsUserControl.methpdname()
_displayResultsUserControl.propertyName;



Similarly to access the a ASPX page’s method or property from the usercontrol


SearchResults myparentPage = (SearchResults)this.Page;
myparentPage.BindRadGrid();


Here SearchResults is the Usercontrool