Tuesday, April 26, 2011

sorting in gridview

protected void BindProductsGrid()
{
DataTable dt =GetAllProducts();
if (dt.Rows.Count > 0)
{
if (ViewState["Sort"] == null)
dt.DefaultView.Sort = "ProductName Asc";
else
dt.DefaultView.Sort = ViewState["Sort"].ToString();

gvProducts.AllowSorting = true;
gvProducts.DataSource = dt.DefaultView;
gvProducts.DataBind();
}
else
{
gvProducts.AllowSorting = false;
DataSetLinqOperators.ShowNoResultFound(dt, gvProducts, "There is no Product Types.");
}
}
public static DataTable GetAllProducts()
{
bhscEntities ese = new bhscEntities();
var pt = (from c in ese.Products
join d in ese.ProductImages on c.ProductId equals d.ProductId
where c.Deleted == false
orderby c.ProductName ascending
select new
{
c.ProductId,
d.Thumbnail,
c.ProductName,
c.ProductOption1Value,
c.ProductOption2Value,
c.ProductOption3Value,
c.SKU,
c.Saleprice
});

DataTable dt = DataSetLinqOperators.CopyToDataTable(pt);
return dt;
}

protected void gvProducts_Sorting(object sender, GridViewSortEventArgs e)
{
if (ViewState["Sort"] != null)
{
if (ViewState["Sort"].ToString().Substring(ViewState["Sort"].ToString().Length - 4, 4).Trim() == "ASC")
ViewState["Sort"] = e.SortExpression + " DESC";
else
ViewState["Sort"] = e.SortExpression + " ASC";
}
else
ViewState["Sort"] = e.SortExpression.ToString() + " Desc";

BindProductsGrid();
}

show and hide buttons or link while printout page

javascript funtion
function ShowHelp(id) {
document.getElementById(id).style.display = "block";
}
function HideHelp(id) {
document.getElementById(id).style.display = "none";
window.print();
setTimeout("ShowHelp('aprint')", 3000);


}
function HideHelp1(id) {
document.getElementById(id).style.display = "none";

setTimeout("ShowHelp('imgbtdelorder')", 3000);


}


calling on button click

a id="aprint" onclick="javascript:HideHelp1('imgbtdelorder');javascript:HideHelp('aprint');" href="JavaScript:window.print();">Print this page a

Saturday, April 23, 2011

2 querysting on postback event of linkbuton

asp:LinkButton ID="lbtprname" runat="server" PostBackUrl='<%# "Description.aspx?Productid="+Eval("ProductId")+"&ProductTypeID="+protypeid %>'

Sunday, February 27, 2011

On Mouse Over show image

function ShowHelp(id) {
document.getElementById(id).style.display = "block";
}
function HideHelp(id) {
document.getElementById(id).style.display = "none";
}


on .aspx page

onmouseover="javascript:ShowHelp('dvthumimage');" onmouseout="javascript:HideHelp('dvthumimage');"

On Mouse over show different image in javascript

function Bind(cControl, imgsrc) {
// t2_ovr.jpg.jpg

cControl.childNodes[0].src = imgsrc;
}
function Clear(cControl, imgsrc) {

cControl.childNodes[0].src = imgsrc;
}



on .aspx page

onmouseover='javascript:Bind(this,"<%# GetAppImagePath(Eval("Thumbnail_Rollover")) %>");' onmouseout='javascript:Clear(this,"<%# GetAppImagePath(Eval("Thumbnail"))

Saturday, February 26, 2011

Asp dotnet 2 yr. exp Interview Questions

Please visit this link for 2 yr. exp. interview questions.

http://www.dotnetcurry.com/ShowArticle.aspx?ID=63

http://dotnetprojectninterviewquestions.blogspot.com/

Wednesday, February 16, 2011