gridview stuff

protected void QtyTextBox_TextChanged(object sender, EventArgs e)

{
var txt = (TextBox)sender;
var container = (GridViewRow)txt.NamingContainer;
decimal? invAmount = Convert.ToDecimal(grvProductsList.Rows[container.RowIndex].Cells[3].Text.Trim());

Label label =
(Label)grvProductsList.Rows[container.RowIndex].Cells[5].FindControl("lblRecQtyError");

if (invAmount < Convert.ToDecimal(txt.Text.Trim()))
{
label.Text = "*";
}
else
{
label.Text = "";
}

//VR003 Start
DataTable dataTable = (DataTable)Session["VRTRN26_GridSelected"];
DataRow dataRow = dataTable.Rows[container.RowIndex];
Decimal orderQty = Decimal.Parse(dataRow["OrderQtyU1"].ToString().Trim());
Decimal invoiceQty = Decimal.Parse(dataRow["InvoiceQtyU1"].ToString().Trim());
Decimal DistOrderQty = Decimal.Parse(dataRow["DistributorQty"].ToString().Trim());

if (Convert.ToDecimal(txt.Text.Trim()) != invoiceQty)
{
grvProductsList.Rows[container.RowIndex].ForeColor = Color.Blue;
}
else
{
string ProStatus = dataRow["PromotionalFlag"].ToString().Trim();
string newItems = dataRow["NewItems"].ToString().Trim();
if (ProStatus == "1")
{
grvProductsList.Rows[container.RowIndex].ForeColor = Color.Green;
}
else if (newItems == "1")
{
grvProductsList.Rows[container.RowIndex].ForeColor = Color.DeepPink;
}
else
{
grvProductsList.Rows[container.RowIndex].ForeColor = grvProductsList.ForeColor;
}
}

if (orderQty != DistOrderQty)
{
grvProductsList.Rows[container.RowIndex].ForeColor = Color.Orange;
}
if (orderQty > 0 && DistOrderQty==0)
{
grvProductsList.Rows[container.RowIndex].ForeColor = Color.Maroon;
}
//VR003 End
}

Read Users' Comments (0)

gridview paging

protected void grvLoadGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grvLoadGrid.SelectedIndex = -1;
grvLoadGrid.PageIndex = e.NewPageIndex;
DataTable dataTable = Session["VRTRN26_GridList"] as DataTable;
dataTable = (DataTable)Session["VRTRN26_GridList"];

grvLoadGrid.DataSource = dataTable;
grvLoadGrid.DataBind();
chkSelectValGrid.Value = "";
}

Read Users' Comments (0)

Exact purpose of http handlers

ASP.NET maps HTTP requests to HttpHandlers. Each HttpHandler enables processing of individual HTTP URLs or groups of URL extensions within an application. HttpHandlers have the same functionality as ISAPI extensions with a much simpler programming model

Ex
1.Default HttpHandler for all ASP.NET pages ->ASP.NET Page Handler (*.aspx)
2.Default HttpHandler for all ASP.NET service pages->ASP.NET Service Handler (*.asmx)

An HttpHandler can be either synchronous or asynchronous. A synchronous handler does not return until it finishes processing the HTTP request for which it is called.

An asynchronous handler usually launches a process that can be lengthy and returns before that process finishes
After writing and compiling the code to implement an HttpHandler you must register the handler using your application's Web.config file.

Read Users' Comments (0)

Different types of caching & Web farm and Web Garden concept in ASP.NET

Caching is a technique of persisting the data in memory for immediate access to requesting program calls. This is considered as the best way to enhance the performance of the application.

Caching is of 3 types:
Output Caching - Caches the whole page.
Fragment Caching - Caches a part of the page
Data Caching - Caches the data


------------------------------------------------------------

A web farm is a multi-server scenario. So we may have a server in each state of US. If the load on one server is in excess then the other servers step in to bear the brunt.
How they bear it is based on various models.

1. RoundRobin. (All servers share load equally)
2. NLB (economical)
3. HLB (expensive but can scale up to 8192 servers)
4. Hybrid (of 2 and 3).
5. CLB (Component load balancer).

A web garden is a multi-processor setup. i.e. a single server (not like the multi server above).
How to implement webfarms in .Net:
Go to web.config and
Here for mode you have 4 options.

a) Say mode inproc (non web farm but fast when you have very few customers).
b) Say mode StateServer (for webfarm)
c) Say mode SqlServer (for webfarm)
Whether to use option b or c depends on situation. StateServer is faster but SqlServer is more reliable and used for mission critical applications.
How to use webgardens in .Net:
Go to web.config and
Change the false to true. You have one more attribute that is related to webgarden in the same tag called cpuMask.

Read Users' Comments (0)

Design a web site with multilingual support in ASP.NET

Multilingual website can be created using Globalization and Localization.

Using Globalization we change the Currency Date Numbers etc to Language Specific Format.

To change the string which is there in the label button etc to language specific string we use Localization.

In Localization we have to create different Resource files for different languages.

During this process we use some classes present in System.Resources/ System.Globalization System.Threading namespaces.

Read Users' Comments (0)

About Session State

Coming to Session State
As we know for every process some default space will be allocated by OS.

In case of InProc Session Info will be stored inside the process where our
application is running.
In case of StateServer Session Info will be stored using ASP.NET State Service.
In case of SQLServer Session info will be stored inside Database. Default DB
which will be created after running InstallSQLState Script is ASPState.

Session Management can be achieved in two ways

1)InProc
2)OutProc

OutProc is again two types
1)State Server
2)SQL Server

InProc
Adv.:
1) Faster as session resides in the same process as the application
2) No need to serialize the data

DisAdv.:
1) Will degrade the performance of the application if large chunk of data is stored
2) On restart of IIS all the Session info will be lost

State Server
Adv.:
1) Faster then SQL Server session management
2) Safer then InProc. As IIS restart
won't effect the session data

DisAdv.:
1) Data need to be serialized
2) On restart of ASP.NET State Service session info will be lost
3)Slower as compared to InProc

SQL Server
Adv.:
1) Reliable and Durable
2) IIS and ASP.NET State Service
restart won't effect the session data
3) Good place for storing large chunk of data

DisAdv.:
1) Data need to be serialized
2) Slower as compare to InProc and State Server
3)Need to purchase Licensed
version of SQL Serve

Read Users' Comments (0)

Useful lamda exp

1)...
Customer foundCustomer = null;
foundCustomer = custList.FirstOrDefault(c =>
c.CustomerId == 4);
Debug.WriteLine(foundCustomer);

The lambda expression syntax in C# looks like this:

c => c.CustomerId == 4

The code begins with the set of parameters to the lambda expression. The => is the “goes to” or lambda operator. The remainder of the code is the expression itself. In this case, checking for the item in the list where CustomerId is 4.


2)...

Customer foundCustomer = null;
var query = from c in custList
where c.CustomerId == 4
select c;
foundCustomer = query.FirstOrDefault();
Debug.WriteLine(foundCustomer);


3)...

Customer foundCustomer = null;
foreach (var c in custList)
{
if (c.CustomerId == 4)
{
foundCustomer = c;
break;
}
}
Debug.WriteLine(foundCustomer);

Read Users' Comments (0)