Friday, July 8, 2011

How to generate proxy class from a web service in asp .net?

open visual studio command prompt and go to root directory and write this command and press enter. MyProxyClass.cs will be created in your root directory.
WseWsdl3 http://hostServer/WebServiceRoot/WebServiceName.asmx?WSDL /out:MyProxyClass.cs

How to show sum at footer in Gridview.

Generally to show sum at footer in GridView we use. GridView's RowDataBound Event. We Create a variable(float/Int) outside of event.
and in RowDataBound Event we check row type. if row type is DataRow than we find the Cell's Text convert it into int and Add it to variable created outside of RowDataBound Event. and When RowType change from DataRow to Footer Row than we put that variable's value in footer.
But i want to tell you short and sweet method for it.
as all of you know generally we use DataTable as  datasource in gridview.
than we should use it
string str = dt.Compute("sum(sGrandTotal)", "").ToString();
now just find the Footer of gridview and put str variable in the cell. like this
grdReport.FooterRow.Cells[7].Text = "Total" + float.Parse(str).ToString( "N2");

How to delete duplicate records from a table ?

delete t1
from tblTable t1, tblTable t2
where t1.sName = t2.sName
and t1.uniqueField > t2.uniqueField
where t1.uniqueFiled should be int