ScriptManager.RegisterStartupScript(this, GetType(), "refresh", "window.setTimeout('window.location.reload(true);',1000);", true);
Tuesday, December 4, 2012
Wednesday, November 21, 2012
Single Line Query for Update all Records using Case Statement
update tblCreditCardConvertTypes set IsDefault=(case when IsDefault =1 then 0 else 1 end)
OR
update tblCreditCardConvertTypes set IsDefault=0 update tblCreditCardConvertTypes set IsDefault ='True'
where ConvertID=6
OR
update tblCreditCardConvertTypes set IsDefault=0 update tblCreditCardConvertTypes set IsDefault ='True'
where ConvertID=6
Language Translation in Asp.Net
in head tag
===============
<meta name="google-translate-customization" content="ab3e055b4f44f8c9-6508da3348829d69-g56af1f4de8a2f969-13"></meta>
============= in body==========================
<div class="translator " style="height:40px;float:right;margin:10px 5px 5px 50px;width:160px;">
<span style= "font:normal 10px verdana;color:#999;align:center; ">WEBSITE TRANSLATOR</span>
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, multilanguagePage: true, gaTrack: true, gaId: 'UA-6642602-1'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script></div>
Monday, May 21, 2012
What is the difference between Finalize() and Dispose()
Finalize () is called by Garbage Collector implicitly to free unmanaged resources. The garbage collector calls this method at some point after there are no longer valid references to the object. There are some resources like windows handles, database connections which cannot be collected by the garbage collector. Therefore the programmer needs to call Dispose() method of IDisposable interface.
Dispose () of IDisposable interface is called by the programmer to explicitly release resources when they are no longer being used. Dispose () can be called even if other references to the object are alive.
Dispose () of IDisposable interface is called by the programmer to explicitly release resources when they are no longer being used. Dispose () can be called even if other references to the object are alive.
Thursday, March 29, 2012
Griview Sorting with Bound Fields in C#.Net
declare static variable before page load event
statis int nSort =0;
write below code in gridview sorting event
protected void gvSearch_Sorting(object sender, GridViewSortEventArgs e)
{
try
{
//sorting Grid For all Records
DataTable dt = dsFG.Tables[0];--------->fill dataset or datatable from database
DataView dv = new DataView(dt);
if (nSort % 2 == 0)
{
dv.Sort = e.SortExpression + " " + "ASC";
}
else
{
dv.Sort = e.SortExpression + " " + "DESC";
}
nSort++;
gvSearch.DataSource = dv;
gvSearch.DataBind();
}
catch (Exception ex)
{
lblmessage.Text = ex.Message;
}
finally
{
}
}
Saturday, January 28, 2012
Passing Data Between Forms in windows Application
In First webform button click eventprivate void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2(textBox1.Text);
frm2.Show(); }In second webform
public Form2(string qs)
{
InitializeComponent();
textBox1.Text = qs;
}
Passing Data Between Forms in windows Application
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2(textBox1.Text);
frm2.Show(); }
Friday, January 27, 2012
Difference between Convert.ToString() VS .ToString() method
Convert.ToString handles null and not throws ObjectReferenceNullException. ToString does not handles the null value and throws the null exception error message.
Example:--
public String FullName = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
Response.Write("<b>.ToString</b><br>");
Response.Write("FullName :" + FullName.ToString());
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Response.Write("<br><br>");
try
{
Response.Write("<b>Convert.ToString</b><br>");
Response.Write("FullName :" + Convert.ToString(FullName));
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
Thursday, January 26, 2012
Sql Union And UnionAll Operators
The SQL UNION operator combines two or more SELECT statements.
The SQL UNION Operator
The UNION operator is used to combine the result-set of two or more SELECT statements.
Notice that each SELECT statement within the UNION must have the same number of columns. The columns must also have similar data types. Also, the columns in each SELECT statement must be in the same order.
SQL UNION Syntax
SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
UNION
SELECT column_name(s) FROM table_name2
Note: The UNION operator selects only distinct values by default. To allow duplicate values, use UNION ALL.
SQL UNION ALL Syntax
SELECT column_name(s) FROM table_name1
UNION ALL
SELECT column_name(s) FROM table_name2
UNION ALL
SELECT column_name(s) FROM table_name2
PS: The column names in the result-set of a UNION are always equal to the column names in the first SELECT statement in the UNION.
SQL UNION Example
Look at the following tables:
"Employees_Norway":
| E_ID | E_Name |
|---|---|
| 01 | Hansen, Ola |
| 02 | Svendson, Tove |
| 03 | Svendson, Stephen |
| 04 | Pettersen, Kari |
"Employees_USA":
| E_ID | E_Name |
|---|---|
| 01 | Turner, Sally |
| 02 | Kent, Clark |
| 03 | Svendson, Stephen |
| 04 | Scott, Stephen |
Now we want to list all the different employees in Norway and USA.
We use the following SELECT statement:
SELECT E_Name FROM Employees_Norway
UNION
SELECT E_Name FROM Employees_USA
UNION
SELECT E_Name FROM Employees_USA
The result-set will look like this:
| E_Name |
|---|
| Hansen, Ola |
| Svendson, Tove |
| Svendson, Stephen |
| Pettersen, Kari |
| Turner, Sally |
| Kent, Clark |
| Scott, Stephen |
Note: This command cannot be used to list all employees in Norway and USA. In the example above we have two employees with equal names, and only one of them will be listed. The UNION command selects only distinct values.
SQL UNION ALL Example
Now we want to list all employees in Norway and USA:
SELECT E_Name FROM Employees_Norway
UNION ALL
SELECT E_Name FROM Employees_USA
UNION ALL
SELECT E_Name FROM Employees_USA
Result
| E_Name |
|---|
| Hansen, Ola |
| Svendson, Tove |
| Svendson, Stephen |
| Pettersen, Kari |
| Turner, Sally |
| Kent, Clark |
| Svendson, Stephen |
| Scott, Stephen |