Wednesday, December 21, 2011

Finding Control in Gridview rows


if you want to find perticular Control inside the GrideView  for below sample Example explains  :-

Whether CheckBox in 5Th row of the gridview is checked or not


foreach(GridViewRow gvRow in gdv.Rows)
{
CheckBox chk = (CheckBox)gdv.Rows[gvRow.RowIndex].FindControl("chkItem"); 

if(chk.Checked)
{
// write your own logic....

}
}

Thursday, September 15, 2011

CrystalReport Problem solving.

Calling Report Page From Main Screen :

ScriptManager.RegisterStartupScript(this, typeof(string), "Showing Modalpopup", "window.open('Report.aspx?ReportName=Test',  'Report', 'width=800,height=400,resizable=yes,status=yes,scrollbars=yes');", true);

Crystal Report Binding Code :

using CrystalDecisions.CrystalReports;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data;

               //Write the Below lines of code in Page_Load Event.
              
                ReportDocument rpt = new ReportDocument();
                string strPath = null;
                DataSet ds = new DataSet();
                ds = (DataSet)Session["ReportData"];
                //get the strReportName from querystring.
                strPath = Server.MapPath(@"~\ModuleName\ReportsFolderPath\" + strReportName + ".rpt");
                rpt.Load(strPath);
                rpt.SetDataSource(ds);
                crvReports.ReportSource = rpt;
                crvReports.RefreshReport();
                crvReports.DisplayGroupTree = false;
                crvReports.DataBind();

Wednesday, April 13, 2011

How to call Codebehind method from Javascript (C# ASP.NET)

<
<
html xmlns="http://www.w3.org/1999/xhtml">head runat="server"><title></title><script type="text/javascript">

alert(
}

</
<
function test() {var VarA = document.getElementById("txtAB").value;'<%=new CodeBehindMethodFromJavascript().GetName("' + VarA + '")%>');</script>head>body><form id="form1" runat="server"><div><input type="text" id="txtAB" /><input type="button" value="ClickMe" onclick="test()" /></div>
</
</
</form>body>html>

Friday, February 25, 2011

Formating DateTime

if u want to save with AM/PM

Example 1:
1. string strSecond = (System.DateTime.Now).ToString("dd-MMM-yyyy hh:mm tt");


if u want to save only date
2. string strSecond = (System.DateTime.Now).ToString("dd-MMM-yyyy ");


Example 2:
1. string strSecond = "25-01-2001"; (or)  "2011-01-25";.ToDateTime(strSecond ).ToString("dd-MMM-yyyy hh:mm tt");
     Convert

Make sure that u have to convert to DB the dateFormat from stringParam which we are sending.

Wednesday, February 23, 2011

Switch Local culture Language sample

if
{
string culture = string.Empty;
culture = Session["language"].ToString();//ddlLang.SelectedItem.Value;// Request.Form["ddlLang"];if (string.IsNullOrEmpty(culture)) culture = "Auto";
UICulture = culture;
Page.Culture = culture;
if (culture != "Auto")
{
CultureInfo ci = new CultureInfo(culture);
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;
}
}
(Session["language"] != null)

Tuesday, January 11, 2011

MaxBuffer length for WCF(30Mb you can return)

<binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

Sunday, January 9, 2011

Close using C# code

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Discount After Bill", "self.close();", true);

Script Manager Popup JavaScript

function popup(url, w, h)
{
var width = w;
var height = h;
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
var params = 'width=' + width + ', height=' + height; params += ', top=' + top + ', left=' + left;
params += ', directories=no'; params += ', location=no'; params += ', menubar=no'; params += ', resizable=yes'; params += ', scrollbars=yes'; params += ', status=no';
params += ', toolbar=no'; newwin = window.open(url, 'windowname5', params);
if (window.focus) {
newwin.focus()
} return false;
}

Saturday, January 1, 2011

Gridview row deleting dynamically

protected void btnDelete_Click(object sender, EventArgs e)
{
DataTable DtList = null
System.Web.UI.WebControls.
ImageButton imgbtn = (System.Web.UI.WebControls.ImageButton)sender

int id = int.Parse(imgbtn.CommandArgument) - 1;DtList = (DataTable)ViewState["DataTable"];DtList.Rows.RemoveAt(id );
DtList.AcceptChanges();
gdvSearchResult.DataSource = DtList;
gdvSearchResult.DataBind();
ViewState[
"DataTable"] = DtList;
}