Friends

Tuesday, May 24, 2011

Inner join in update query

update tbl_document set isPaid=1 from tbl_document D
inner join tbl_transcription TR on TR.tran_id=D.tran_id
where TR.user_id=@user_id

Thursday, May 19, 2011

Prevent direct access of asp.net page


if (Request.UrlReferrer != null)
{
Label1.Text = Request.UrlReferrer.ToString();

}
else
{
Response.Redirect("default.aspx");
}

Thursday, March 31, 2011

private decimal TotalSales = (decimal)0.0;

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
TotalSales += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "amount"));
else if (e.Row.RowType == DataControlRowType.Footer)
//e.Row.Cells[1].Text = String.Format("{0:c}", TotalSales);
e.Row.Cells[1].Text = TotalSales.ToString();
}

Monday, January 31, 2011

Failed to load ViewState error in asp.net

Error: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

Solution:

In the place holder EnableViewState="False"