This post explains different ways to get Session, ViewBag or server side variable’s values in your external JS files. In Rich UI web app, there are many JS files having thousands lines of code and It’s common to need of accessing server side variable or session in external js file. Let’s see different ways to get it in ASP.NET MVC 3. …
Sometimes we need to convert one data type to another data type to map columns in sql server. You might not be allowed to change table structure directly. In this case you’ve to convert in your query or stored procedure. Suppose you’ve to convert money data-type to decimal for greater precision in calculation then you can do it easily using Cast or Convert methods. …
In my post, I explained how we can create a simple wizard using jQuery. In this post, we’ll see how asp.net gridview can be displayed in wizard format. Sometimes, gridview is used to take input from user when multiple fields are required many times. It is not user friendly, We can use wizard but not easy to handle on server side as in gridview. So, It’s better to convert ASP.NET gridview to jQuery wizard. So, no need to change on server side and UI is also more user convenient. We’ll convert gridview structure to wizard structure as explained in this post and use wizard.js. …
Generally, We use SQL Where .. IN Statement to determine whether a specified value matches ANY value in a sub-query or a list. But sometimes we require to get data which have ALL specified values, not ANY value. In this post, we’ll see how to accomplish it. Let’s take an example, Consider following data in Orders table …
It explains how to implement an audit trail quickly by creating shadow table for each table in database and triggers to log every time when a record is inserted, updated or deleted in the table. …
It explains how to implement asp.net gridview sorting functionality when gridview datasource is Anonymous Type. Suppose you are using Entity Framework OR LINQ to sql, getting data with a particular structure having different columns from different tables (Anonymous Type) using LINQ and you have defined it as a datasource of gridview. It’s okay to display data. Now, you have to implement sorting feature. One way is to convert Anonymous Type to Datatable and sort it defaultview, but it’s too complex. You might have tasted dynamic sorting with extension method as mentioned here and here but not useful for Anonymous type. Another way is to use switch case for sortexpression and use OrderBy and OrderByDescending for each column. It’s not a generalize solution. then what….??? …
This article explains how to perform insert, update and delete operations in ASP.NET GridView with Entity Framework. Let us take an example to perform CRUD operations using Entity Framework Database First approach. Suppose we’ve to work on Customer table having CategoryID as foreign key. …
In my previous post, I explained how to group HTML table rows with jQuery. This post explains How to do same thing using ASP.NET Gridview control on server side. The logic is same to check row by row. If data is same in next row’s cell, hide next row’s cell and increase rowspan of current row’s cell. …
Suppose you have to do a task repeatedly with different objects of database, for example, you have to generate code or stored procs of table in the specific format, you created your custom SQL script which takes table name and generate the code. But each time, you have to execute query and pass table name.
What’ll happen If you right click on the table and select your script to execute. It’ll save bunch of time as well as stop you getting irritated
Let’s see how to do using SSMS Tools Pack.
…
In my post, I discussed different client side APIs and Methods of asp.net validator Controls. Now suppose if you have customized validation on client side, what’ll happen on server side? We need to do same on server side. Let’s understand this step by step by taking same example. Suppose you have to disable password’s requiredfieldvalidator when ‘Allow me‘ checkbox is true. You have disabled validator on checkbox click using ValidatorEnable javascript method. Now on server side button click, if you validate and check for isValid, it is always false and you will see error message in validationsummary even if checkbox is checked. Client side bypasses validation but on server side it’s stucked and our object is defeated. …
If you are developing a web service client, you access web services, pass parameters and test the response to know the behavior of service. It can be easily accomplished using Poster Firefox add-on. You can create your own HTTP request with custom parameters, perform the action (GET,POST, PUT, DELETE..etc) and inspect the result. It saves bunch of time to create web-service based application.
Let’s see sample to use Poster. …
There are tons of articles to display total in asp.net gridview footer row. The common approach to implement this is:
1. Create template field of the column which is to be totalled.
2. Define FooterTemplate and add Label control.
3. Take a variable and add value of each row in GridView1_RowDataBound event.
4. Find label control in footer and assign the variable.
It’s too complex. Let’s see how to take advantage of LINQ or Lambda expression and skip these steps. …
If you are using LINQ or Lambda expression and getting error: InvalidOperationException “Sequence contains no elements”. It means you are trying to retrieve an element from an empty sequence(may be returned by LINQ query). There are some basic rules to handle this in LINQ or lambda expression. …
In your web app, If you don’t want to store images on your hosting to save space and bandwidth, Flickr is the best option for you. Flickr is the most popular online photo management and sharing app. phpFlickr is an open source wrapper class of Flickr’s API to upload and retrieve pictures and related information. This post explains how to display user photo in profile page when user logs in.
…
