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)

Useful regular expressions

Regex syntax is :

Regex re = new Regex("Regular Expression string",Regular Expression Options);

Regular Expression Options are options that we can use along with regular expression like RegexOptions.IgnoreCase or RegexOptions.Compiled

Here I am lisitng some Regular Expressions:

[a-zA-Z]* - Regular Expression to allow only charactors

[0-9]* - Regular Expression to allow only numbers

[a-zA-Z0-9]* - Regular Expression to allow only alphanumeric charactors

[0-9]*(\.[0-9]{1,2})? - Regular Expression to validate a float number with 1 or 2 decimal points

Read Users' Comments (0)

XAML Overview (WPF)

XAML itself is a larger language concept than WPF.



XAML is a declarative markup language. As applied to the .NET Framework programming model, XAML simplifies creating a UI for a .NET Framework application.
You can create visible UI elements in the declarative XAML markup, and then separate the UI definition from the run-time logic by using code-behind files, joined to the markup through partial class definitions. XAML directly represents the instantiation of objects in a specific set of backing types defined in assemblies. This is unlike most other markup languages, which are typically an interpreted language without such a direct tie to a backing type system. XAML enables a workflow where separate parties can work on the UI and the logic of an application, using potentially different tools.

When represented as text, XAML files are XML files that generally have the .xaml extension. The files can be encoded by any XML encoding, but encoding as UTF-8 is typical.

The following example shows how you might create a button as part of a UI. This example is just intended to give you a flavor of how XAML represents common UI programming metaphors.


Read Users' Comments (0)

Design Patterns in .net

Creational Patterns
Abstract Factory Creates an instance of several families of classes
Builder Separates object construction from its representation
Factory Method Creates an instance of several derived classes
Prototype A fully initialized instance to be copied or cloned
Singleton A class of which only a single instance can exist

Structural Patterns
Adapter Match interfaces of different classes
Bridge Separates an object’s interface from its implementation
Composite A tree structure of simple and composite objects
Decorator Add responsibilities to objects dynamically
Facade A single class that represents an entire subsystem
Flyweight A fine-grained instance used for efficient sharing
Proxy An object representing another object

Behavioral Patterns
Chain of Resp. A way of passing a request between a chain of objects
Command Encapsulate a command request as an object
Interpreter A way to include language elements in a program
Iterator Sequentially access the elements of a collection
Mediator Defines simplified communication between classes
Memento Capture and restore an object's internal state
Observer A way of notifying change to a number of classes
State Alter an object's behavior when its state changes
Strategy Encapsulates an algorithm inside a class
Template Method Defer the exact steps of an algorithm to a subclass
Visitor Defines a new operation to a class without change

Read Users' Comments (0)


Read Users' Comments (0)

Path


Read Users' Comments (0)

What is FILESTREAM

What is FILESTREAM?

FILESTREAM is a new feature introduced in SQL Server 2008 which provides an efficient storage and management option for BLOB data.

Many applications that deal with BLOB data today stores them in the file system and stores the path to the file in the relational tables. Storing BLOB data in the file system is more efficient that storing them in the database. However, this brings up a few disadvantages as well. When the BLOB data is stored in the file system, it is hard to ensure transactional consistency between the file system data and relational data.

Some applications store the BLOB data within the database to overcome the limitations mentioned earlier. This approach ensures transactional consistency between the relational data and BLOB data, but is very bad in terms of performance.

FILESTREAM combines the benefits of both approaches mentioned above without the disadvantages we examined. FILESTREAM stores the BLOB data in the file system (thus takes advantage of the IO Streaming capabilities of NTFS) and ensures transactional consistency between the BLOB data in the file system and the relational data in the database.

Read Users' Comments (0)

Best Picks...

What role does the ScriptManager play?

The ScriptManager manages all ASP.NET AJAX resources on a page and renders the links for the ASP.NET AJAX client libraries, which lets you use AJAX functionality like PageMethods, UpdatePanels etc. It creates the PageRequestManager and Application objects, which are prominent in raising events during the client life cycle of an ASP.NET AJAX Web page. It also helps you create proxies to call web services asynchronously.

Read Users' Comments (0)

Design Patterns

There are three basic classification of patterns Creational, Structural, Behavioral patterns.


Creational Patterns
==============

Abstract Factory:- Creates an instance of several families of classes
Builder :- Separates object construction from its representation
Factory Method:- Creates an instance of several derived classes
Prototype:- A fully initialized instance to be copied or cloned
Singleton:- A class in which only a single instance can exist

Structural Patterns
==============

Adapter:-Match interfaces of different classes.
Bridge:-Separates an object’s interface from its implementation.
Composite:-A tree structure of simple and composite objects.
Decorator :-Add responsibilities to objects dynamically.
Façade:-A single class that represents an entire subsystem.
Flyweight:-A fine-grained instance used for efficient sharing.
Proxy:-An object representing another object.

Behavioral Patterns
===============

Mediator:-Defines simplified communication between classes.
Memento:-Capture and restore an object's internal state.
Interpreter:-A way to include language elements in a program.
Iterator:-Sequentially access the elements of a collection.
Chain of Resp:-A way of passing a request between a chain of objects.
Command:-Encapsulate a command request as an object.
State:-Alter an object's behavior when its state changes.
Strategy:-Encapsulates an algorithm inside a class.
Observer:-A way of notifying change to a number of classes.
Template Method:-Defer the exact steps of an algorithm to a subclass.
Visitor:-Defines a new operation to a class without change.




Read Users' Comments (0)

TSQL: Concatenate Multiple Rows into String

use Northwind

declare @CategoryList varchar(1000)
select @CategoryList = coalesce(@CategoryList + ‘, ‘, ”) + CategoryName from Categories

select ‘Results = ‘ + @CategoryList

Read Users' Comments (0)

datatable grouping

Ex : var masterGroups = (from row in dtRetCls.AsEnumerable()
group row by row["GroupDescription"] into groupedTable
select new
{
x = groupedTable.Key
}
).ToList();

Select data rows

DataRow[] drx = dtRetCls.Select("GroupDescription= '" + item.x + "' ");

Read Users' Comments (0)

Computed Column Specification

Ex :

(((isnull([AuthorizedQtyU1],isnull([InvoiceQtyU1],(0)))-isnull([ReceivedQtyU1],(0)))-isnull([DamagedQtyU1],(0)))-isnull([MissingQtyU1],(0)))

Is Persisted = no

(datediff(minute,[StartTime],[EndTime]))

Is Persisted = no

Read Users' Comments (0)

filter generic list items

BatchExeProduct batchExeProductObject = batchExeProducts.Find(delegate(BatchExeProduct ep) {return ep.ExecutiveCode == exeCode; });

Read Users' Comments (0)

Remove cache in asp.net page

So far I've tried the page directive:

@ OutputCache Duration="1" Location="None"

The Meta tags:

<meta http-equiv="Expires" CONTENT="0">

<meta http-equiv="Cache-Control" CONTENT="no-cache">

<meta http-equiv="Pragma" CONTENT="no-cache">

And the code:

Response.ExpiresAbsolute = DateTime.Now

Response.Expires = -1441

Response.CacheControl = "no-cache"

Response.AddHeader("Pragma", "no-cache")

Response.AddHeader("Pragma", "no-store")

Response.AddHeader("cache-control", "no-cache")

Response.Cache.SetCacheability(HttpCacheability.NoCache)

Response.Cache.SetNoServerCaching()

Read Users' Comments (0)

filter sql

WHERE convert (datetime, convert (varchar, datecol, 101), 101) = @yourdate

Read Users' Comments (0)