Monday, 27 February 2012

How can we display images in datalist using asp.net

I am using DataList control  but you can easily use same technique for Repeater and GridView control. 
 
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
   Width="100%" BorderColor="#336699" BorderStyle="Solid" BorderWidth="2px">
  
   <ItemTemplate>
      <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductName") %>' Font-Bold="True"
         Font-Size="10pt" ForeColor="#336699" Width="100%" />
      <br />
      <asp:Image ID="Image1" runat="server"
         ImageUrl='<%# "GetImage.aspx?id=" + Eval("ProductID") %>' />

   </ItemTemplate>
   <ItemStyle HorizontalAlign="Center" VerticalAlign="Top"  />
</asp:DataList>


Friday, 24 February 2012

Difference between CLS and CTS


What is a CLR?
Full form of CLR is Common Language Runtime and it forms the heart of the .NET
framework.All Languages have runtime and its the responsibility of the runtime to take care of
the code execution of the program. Java has Java Virtual Machine, Similarly .NET has CLR.The responsibilities of CLR are Garbage Collection, Code Access Security, Code Verification, IL( Intermediate language ).

Implementation of fragment caching in asp.net

Lets first create a user control.

ASCX PAGE

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CahceUserControl.ascx.cs"

Inherits="CahceUseControl" %>

<%@ OutputCache Duration="5" VaryByParam="None" %>



<p><asp:Label ID="lblTime" runat="server" EnableViewState="false"

ForeColor="GradientActiveCaption" /></p>

How can we use groupby statement in sqlserver

The GROUP BY clause can be used in a SELECT statement to collect data across multiple records and group the results by one or more columns.
The syntax for the GROUP BY clause is:
SELECT column1, column2, ... column_n, aggregate_function (expression)
FROM tables
WHERE predicates
GROUP BY column1, column2, ... column_n;
aggregate_function can be a function such as sum , count, Min and Max.

Wednesday, 22 February 2012

Find the nth highest salary in sql -Query to retrieve value

The following solution is for getting 6th highest salary from Employee table :-
 SELECT TOP 1 salaries
FROM (
SELECT DISTINCT TOP 6 salaries
FROM employee
ORDER BY salary DESC) a
ORDER BY salary


How can we insert image using file upload control using asp.net

1.Firstly create Table
2.Secondly create store procedure

Then .cs page code below:-

if (FileUpload1.HasFile)
            {
                string productname = txtProductName.Text;
                byte[] productimage = FileUpload1.FileBytes;

Wednesday, 1 February 2012

Learn about loops in c#

While Loop:- While loop is use when we have to check a condition and then continues to execute a block of code as long as the condition evaluates to boolean value of true.
Syntax:- while (<boolean expression>) { <statements> }.
using System;
                                class whileloops
                                 {
                                    public static void main()
                                       {
                                          int abc=0;
                                          while(abc<20)
                                            {
                                                console.write("{0}", abc)
                                               abc++;
                                              }

Implementation of Interface in C#

An interface is look like classes but in interface have no implementation. It contains the declaration of  events,methods, indexers and properties. Interfaces provide only declaration because they are inherited by classes and structs which must provide implementation for each interface member declared.

Defining an Interface:-
interface IUInterface
{
 void ImplementationToMethod();
}