Content feed Comments Feed

The Official ASATO Site

Hi, welcome to my blog. ASP,asp.net,Health,Javascript,JQUERY

Archive for March, 2010

How Get Strong, Toned Legs ?

Posted by admin On March - 24 - 2010

This routine targets all of your leg muscles, from your butt down. In addition to making your lower half look fabulous, this workout will also help you walk faster. A recent study found that simply doing one move to strengthen your quads (the fronts of your thighs) could increase your walking speed by 15 percent. That’s equivalent to increasing your pace from 3.5 mph to 4 mph. Imagine what you could do if you shape up all of your lower-body muscles. These exercises also challenge your balance, giving your core muscles an extra workout, and improve your posture for a stronger, pain-free stride. (If the balance challenge is too hard, hold on to something sturdy.)

You’ll need a resistance band for at least two of the following moves. Position the band as described, and check that it’s secure before you begin the exercise. If you’re instructed to make a loop from the band, be aware that the larger the loop, the easier the resistance will be; the smaller the loop, the harder it will be. You can also increase the resistance by moving farther away from the anchor point.

If you need to tie the band in a loop around your lower legs for an exercise, you can wrap it around your legs twice for maximum resistance. Just remember, don’t sacrifice good form for increased challenge. Stretching and releasing the band’s resistance with control is key to maximizing toning and avoiding injury. Don’t let the band snap back once you’ve reached the top of the move; pause, then slowly release, resisting against the band’s pull as you do.

Practice this routine 2 days a week for 4 weeks. Start with 6 to 8 repetitions, working up to 12 to 15 reps by the fourth week.

Cross Leg Swing (targets inner thighs)

Main move: Attach the resistance band near the floor around a sturdy furniture leg, a railing, or under a heavy piece of furniture so that it forms a loop. Stand so that the band is on your left. Put the band around your left foot near your ankle. Step away from the anchor point until the band is taut when your left leg is extended out to the side, toes pointed.

Flex your left foot, contract your inner thigh, and swing your leg across the front of your body toward your right leg. Hold, then slowly return to start without letting your left foot touch the floor between reps.

Make it easier: Lower your foot to the floor between reps.

Make it harder: Hold your leg in the up position and pulse it twice, lifting and lowering an inch or so, before returning to start for your next rep.

Moving Squat (targets quads, and outer thighs)

Main move: Stand with your feet together and your arms at your sides. Step your right foot out to the side 2 to 3 feet, bend your hips and knees, and sit back as if you’re lowering into a chair. Simultaneously, swing your arms forward to about chest height. Keep your knees over your feet, not out past your toes or rolling in toward each other. Your upper body will lean forward about 45 degrees. Stand back up, bringing your left foot toward your right. Step to the right again. Continue moving to the right until you run out of space or you’ve completed all of the reps. Then repeat to the left. You may need to alternate going side to side, depending on how much space you have.

Make it easier: Do stationary squats with your feet about shoulder-width apart the entire time.

Make it harder: Tie a resistance band around your lower legs so that it’s taut, then step and squat.

One-Leg Squat (targets quads, glutes, and hamstrings)

Main move: Balance on your right leg with the toes of your left foot lightly touching the floor and your arms at your sides. Bend your hips and right knee and sit back as if you were lowering halfway into a chair. Let your arms swing forward to about chest height. Keep your right knee behind your toes. Press into your right foot and stand back up.

Make it easier: Hold onto a chair for balance and/or don’t sit back as far.

Make it harder: Balance on your right leg with your left foot completely off the floor.

Rear Kick (targets glutes and hamstrings)

Main move: Attach the resistance band near the floor around a sturdy furniture leg, a railing, or under a heavy piece of furniture so that it forms a loop. Stand facing the anchor point and put the band around your right foot near your ankle. Step backward if needed so the band is taut. Balancing on your left leg, with your left knee slightly bent, press your right leg back, with your foot flexed, and squeeze your butt. Hold and slowly lower without touching your foot to the floor between reps.

Make it easier: Lower your foot to the floor between reps.

Make it harder: Hold your leg in the up position and pulse it twice, lifting and lowering it an inch or so, before lowering it completely.

Reverse Lunge (targets quads, glutes, and calves)

Main move: Stand with your feet together and your arms at your sides. Step 2 to 3 feet behind you with your right foot, toes pointing forward, and bend your knees so that the right one is almost to the floor (your right heel will come off the floor). Simultaneously, swing your arms forward to about chest height. Keep your left knee directly over your left ankle; if it’s coming forward, shift your hips back or take a bigger step back. Press into your front foot and stand back up, bringing your feet together. Repeat, stepping back with the left leg. Continue alternating legs until you complete the recommended number of reps with each leg.

Make it easier: Do stationary lunges, with your right foot 2 to 3 feet in front of your left foot (heel will be up) the entire time.

Make it harder: Add a heel lift. As you stand back up and bring your feet together, rise up onto your toes. Hold for a second, then lower and step back into the next lunge.

How to Upload multiple files in asp.net

Posted by admin On March - 23 - 2010

In asp.net 2.0, if you want to upload a file, you can use FileUpload server control in your in your applications.like this:
ASPX code:

?View Code CSHARP
1
2
3
4
<div>
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click"  Text="Upload--File" />
        <asp:Label ID="Label1" runat="server"></asp:Label></div>

ASPX.CS code:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
            try
            {
                FileUpload1.SaveAs("G:\\Uploads\\" +  FileUpload1.FileName);
                Label1.Text = "File name: " +
                     FileUpload1.PostedFile.FileName + "<br>" +
                     FileUpload1.PostedFile.ContentLength + " kb<br>" +
                     "Content type: " +
                     FileUpload1.PostedFile.ContentType;
            }
            catch (Exception ex)
            {
                Label1.Text = "ERROR: " + ex.Message.ToString();
            }
        else
        {
            Label1.Text = "You have not specified a file.";
        }
    }

But, if we want to Upload multiple files, how can we do ?
aspx:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Upload multiple files</title>
 
  <script type="text/javascript">
    function addFiles() {
      var div = document.createElement("div");
      var f = document.createElement("input");
      f.setAttribute("type", "file")
      f.setAttribute("name", "File")
      f.setAttribute("size", "40")
      div.appendChild(f)
      var d = document.createElement("input");
      d.setAttribute("type", "button")
      d.setAttribute("onclick", "deteFile(this)");
      d.setAttribute("value", "remove")
      div.appendChild(d)
      document.getElementById("_container").appendChild(div);
    }
 
    function deteFile(o) {
      while (o.tagName != "DIV") o = o.parentNode;
      o.parentNode.removeChild(o);
    }
  </script>
</head>
<body>
  <form id="form1" runat="server" method="post" enctype="multipart/form-data">
  <h3>Upload multiple files</h3>
   <div id="_container">
    <input type="file" size="50" name="File" />
  </div>
  <div>
    <input type="button" value="Add" onclick="addFiles()" />
  </div>
  <div style="padding:10px 0">
    <asp:Button runat="server" Text="Upload files" ID="UploadButton" onclick="UploadButton_Click"></asp:Button>
  </div>
  <div>
    <asp:Label ID="Label1" runat="server"  Width="500px" BorderStyle="None" BorderColor="White"></asp:Label>
  </div>
  </form>
</body>
</html>

aspx.cs:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
protected void UploadButton_Click(object sender, EventArgs e)
    {
      ///foreach File form
      HttpFileCollection files = HttpContext.Current.Request.Files;
      strMsg.Append("file list is:<hr color='red'/>");
      try
      {
        for (int iFile = 0; iFile < files.Count; iFile++)
        {
          HttpPostedFile postedFile = files[iFile];
          string fileName, fileExtension;
          fileName = System.IO.Path.GetFileName(postedFile.FileName);
          if (fileName != "")
          {
            fileExtension = System.IO.Path.GetExtension(fileName);
            strMsg.Append("type:" + postedFile.ContentType.ToString() + "<br>");
            strMsg.Append("client dress:" + postedFile.FileName + "<br>");
            strMsg.Append("file name:" + fileName + "<br>");
            strMsg.Append("fileExtension :" + fileExtension + "<br><hr>");
            postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("photoshops/") + fileName);
          }
        }
        Label1.Text = strMsg.ToString();
      }
      catch (System.Exception Ex)
      {
        Label1.Text = Ex.Message;
      }
    }

Note: the form must set enctype=”multipart/form-data”

Note: After calling this method, be sure to SqlDataReader to Close.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
	public static string connectionString = "server=192.168.1.1;database=TestDB;uid=sa;pwd=sa";
	public static SqlDataReader ExecuteReader(string strSQL)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand(strSQL, connection);
            try
            {
                connection.Open();
                SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                return myReader;
            }
            catch (System.Data.SqlClient.SqlException e)
            {
                throw e;
            }   
 
        }

Convert Enum to List

Posted by admin On March - 22 - 2010

An enumeration is a named constant whose underlying type is any integral type except Char. If no underlying type is explicitly declared, Int32 is used. Programming languages typically provide syntax to declare an enumeration that consists of a set of named constants and their values.
example1:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
enum class Colors
{
   public enum SetType {
   	Red = 1,
   	Green = 2,
   	Blue = 4,
   	Yellow = 8
   }
};

We can get value from this enum:

?View Code CSHARP
1
Console.WriteLine(Colors.Green.ToString());

We can takes an enum type and returns a generic list populated with each enum item.
first,we write a class name

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace wind-flowers.Core {
    [Serializable]
    public class SetCollections {
        public SetCollections() { }
        public SetCollections(string id) {
            this._id = id;
        }
        public SetCollections(string id, string title) {
            this._id = id;
            this._title = title;
        }
 
        private string _id;
        public string Id {
            get { return _id; }
            set { _id = value; }
        }
        private string _title;
        public string Title {
            get { return _title; }
            set { _title = value; }
        }
    }
}

then , we can get a List from enum Colors:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
	public  List<SetCollections> SetList() {
            List<SetCollections> List = new List<SetCollections>();
            String[] EnumTypes = Enum.GetNames(typeof(Colors.SetType));
            foreach (int i in Enum.GetValues(typeof(Colors.SetType))) {
                SetCollections collecte = new SetCollections(
                        i.ToString(), 
                        Enum.GetName(typeof(Colors.SetType), i),
                        getItems(i.ToString())
                    );
                List.Add(collecte);
            }
            return List;
        }

A Cool jQuery Gallery Plugin

Posted by admin On March - 22 - 2010

We will build a custom gallery that scans a folder of images and outputs a cool image gallery, utilizing asp.net, CSS, jQuery and the lightBox plug-in.

Demo: A Cool jQuery Gallery

Download: down

?View Code CSHARP
1
2
3
4
5
<link rel="stylesheet" type="text/css" href="lightbox/css/jquery.lightbox-0.5.css" /> 
<link rel="stylesheet" type="text/css" href="demo.css" /> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 
<script type="text/javascript" src="lightbox/js/jquery.lightbox-0.5.pack.js"></script> 
<script type="text/javascript" src="script.js"></script>

The demo.css is:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 .clear{
	clear:both;
}
 
a, a:visited {
	color:#00BBFF;
	text-decoration:none;
	outline:none;
}
 
a:hover{
	text-decoration:underline;
}
 
#container{
	width:890px;
	margin:20px auto;
}
 
 
div.nomargin{
	margin-right:0px;
}
 
.pic{
	float:left;
	margin:0 15px 15px 0;
	border:5px solid white;
	width:200px;
	height:250px;
}
 
.pic a{
	width:200px;
	height:250px;
	text-indent:-99999px;
	display:block;
}
 
h1{
	font-size:28px;
	font-weight:bold;
	font-family:"Trebuchet MS",Arial, Helvetica, sans-serif;
}
 
h2{
	font-weight:normal;
	font-size:14px;
 
	color:white;
}

the html is:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
	<div id="gallery"> 
		<div class="pic " style="background:url(gallery/ladybug.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/ladybug.jpg" title="ladybug" target="_blank">ladybug</a> 
		</div> 
		<div class="pic " style="background:url(gallery/bw.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/bw.jpg" title="bw" target="_blank">bw</a> 
		</div> 
		<div class="pic " style="background:url(gallery/bw-lingere.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/bw-lingere.jpg" title="bw-lingere" target="_blank">bw-lingere</a> 
		</div> 
		<div class="pic nomargin" style="background:url(gallery/red-head.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/red-head.jpg" title="red-head" target="_blank">red-head</a> 
		</div> 
		<div class="pic " style="background:url(gallery/wedding_catwalk.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/wedding_catwalk.jpg" title="wedding_catwalk" target="_blank">wedding_catwalk</a> 
		</div> 
		<div class="pic " style="background:url(gallery/tiger.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/tiger.jpg" title="tiger" target="_blank">tiger</a> 
		</div> 
		<div class="pic " style="background:url(gallery/lonely-anguish.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/lonely-anguish.jpg" title="lonely-anguish" target="_blank">lonely-anguish</a> 
		</div> 
		<div class="pic nomargin" style="background:url(gallery/promotion.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/promotion.jpg" title="promotion" target="_blank">promotion</a> 
		</div> 
		<div class="pic " style="background:url(gallery/pristine-lake.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/pristine-lake.jpg" title="pristine-lake" target="_blank">pristine-lake</a> 
		</div> 
		<div class="pic " style="background:url(gallery/tattoo.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/tattoo.jpg" title="tattoo" target="_blank">tattoo</a> 
		</div> 
		<div class="pic " style="background:url(gallery/white-stallion.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/white-stallion.jpg" title="white-stallion" target="_blank">white-stallion</a> 
		</div> 
		<div class="pic nomargin" style="background:url(gallery/furry-feline.jpg) no-repeat 50% 50%;"> 
		<a href="gallery/furry-feline.jpg" title="furry-feline" target="_blank">furry-feline</a> 
		</div><div class="clear"></div> 
	</div>

the script.js is:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
$(document).ready(function(){
 
	$('.pic a').lightBox({
 
		imageLoading: 'lightbox/images/loading.gif',
		imageBtnClose: 'lightbox/images/close.gif',
		imageBtnPrev: 'lightbox/images/prev.gif',
		imageBtnNext: 'lightbox/images/next.gif'
 
	});
 
});

What is List and How to bind List to GridView?

Posted by admin On March - 12 - 2010

C# List Examples
Lists are dynamic arrays in the C# language. They can grow as needed when you add elements. They are called generic collections and constructed types.You need to use < and > in the List declaration.
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.

Examples 1

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
        List<string> dinosaurs = new List<string>();
        dinosaurs.Add("one");
        dinosaurs.Add("two");
        dinosaurs.Add("three");
        dinosaurs.Add("four");
        dinosaurs.Add("five");
        foreach(string din in dinosaurs)
        {
            Console.WriteLine(dinosaur);
        }

Examples 2
This example shows how you can create a new List of unspecified size, and add object to it.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class Client
{
    public Client(string Name, int Age)
    {
        _Name = Name;
        _Age = Age;
    }
    private int _Age;
    public int Age
    {
        get { return _Age; }
        set { _Age = value; }
    }
    private string _Name;
    public string Name
    {
        get { return _Name; }
        set { _Name = value; }
    }
}
?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
List<Client> lst = new List<Client>();
lst.Add(new Client("Mike", 20));
lst.Add(new Client("Tom", 22));
foreach(Client cit in lst)
{
     Console.WriteLine(cit.Name);
     Console.WriteLine("------------");
     Console.WriteLine(cit.Age);
     Console.WriteLine(cit.Name);
}

How to bind List<> to GridView?

?View Code CSHARP
1
2
GridView1.DataSource = lst;
GridView1.DataBind();

Life Cycle of ASP.NET Page

Posted by admin On March - 11 - 2010

When a page request is sent to the Web server, whether through a submission or location change, the page is run through a series of events during its creation and disposal. When we try to build ASP.NET pages and this execution cycle is not taken into account, we can cause a lot of headaches for ourselves. However, when used and manipulated correctly, a page’s execution cycle can be an effective and powerful tool. Many developers are realizing that understanding what happens and when it happens is crucial to effectively writing ASP.NET pages or user controls. So let’s examine in detail the ten events of an ASP.NET page, from creation to disposal. We will also see how to tap into these events to implant our own custom code.

1.Web page request comes from browser.
2.IIS maps the ASP.NET file extensions to ASPNET_ISAPI.DLL, an ISAPI extension provided with ASP.NET.
3.ASPNET_ISAPI.DLL forwards the request to the ASP.NET worker process (ASPNET_WP.EXE or W3P.EXE).
4.ISAPI loads HTTPRuntime and passes the request to it. Thus, HTTP Pipelining has begun.
5.HTTPRuntime uses HttpApplicationFactory to either create or reuse the HTTPApplication object.
6.HTTPRuntime creates HTTPContext for the current request. HTTPContext internally maintains HTTPRequest and HTTPResponse.
7.HTTPRuntime also maps the HTTPContext to the HTTPApplication which handles the application level events.
8.HTTPApplication runs the HTTPModules for the page requests.
9.HTTPApplication creates HTTPHandler for the page request. This is the last stage of HTTPipelining.
10.HTTPHandlers are responsible to process request and generate corresponding response messages.
11.Once the request leaves the HTTPPipeline, page level events begin.
12.Page Events are as follows: PreInit, Init, InitComplete, PreLoad, Load, Control events (Postback events), Load Complete, PreRender, SaveStateComplete, Render and Unload.
13.HTTPHandler generates the response with the above events and sends back to the IIS which in turn sends the response to the client browser.
null

How to use Log4net in ASP.NET

Posted by admin On March - 11 - 2010

This article describes the basic steps to be followed for using Log4net in a web application. Log4net is an open source library that allows .NET applications to log statements to a variety of targets.

Download Log4net.

extract the downloaded folder and look for /bin/net/2.0/Log4net.dll

Right-Click the project name and Add a Reference to Log4net.dll

Copy paste the following log4net configuration settings to log4net.config file.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
	<root>
		<level value="DEBUG" />
		<appender-ref ref="RollingLogFileAppender"/>
	</root>
	<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
		<file value="logsapp.log" />
		<appendToFile value="true" />
		<rollingStyle value="Size" />
		<maxSizeRollBackups value="10" />
		<maximumFileSize value="100KB" />
		<staticLogFileName value="true" />
		<layout type="log4net.Layout.PatternLayout">
			<conversionPattern value="%d [%t]%-5p %c [%x] - %m%n" />
		</layout>
	</appender>
	<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
		<file value="logsapp.log" />
		<appendToFile value="false" />
		<datePattern value="-dddd" />
		<rollingStyle value="Date" />
		<layout type="log4net.Layout.PatternLayout">
			<conversionPattern value="%d [%t]%-5p %c [%x] - %m%n" />
		</layout>
	</appender>
</log4net>

Create a logs file in your project directory.

Add Global.asax to your project and then add the following function to it.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
void Application_Start(object sender, EventArgs e)
{
	// Code that runs on application startup
	ConfigureLogging();
}
protected void ConfigureLogging()
{
	string logFile = HttpContext.Current.Request.PhysicalApplicationPath + "log4net.config";
	if (System.IO.File.Exists(logFile))
	{
		log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(logFile));
	}
}

Copy follow code in your Page_Load demonstrates how to log Debug Information and Errors.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
protected static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 
protected void Page_Load(object sender, EventArgs e)
{
	try
	{
		log.Debug("In Page Load Function");
		log.Debug("Going to generate divide by zero");
		int a = 0;
		int b = 10 / a;
	}
	catch (Exception ex)
	{
		log.Error(ex.Message, ex);
	}
}

Compile and run the application, and you’ll see output to the console.

Understanding DataItem

Posted by admin On March - 10 - 2010

You’ve undoubtedly made frequent use of the DataItem property, namely when using the DataBinding syntax, to output a value:

?View Code CSHARP
1
<%# DataBinder.Eval(Container.DataItem, "customerId") %>

It’s important to understand that DataItem is actually an object, and that when you use the DataBinder.Eval function, it basically needs to figure out what type of object it is and how to get “customerId” from it. That’s because your data source can be different things, such as a DataSet or DataView, an ArrayList or HashTable, a custom collection, and more. Binding happens on a row-by-row basis, and DataItem actually represents the current row being bound. For a DataSet, DataTable, or DataView, DataItem is actually an instance of DataRowView.When you are binding to a collection, DataItem is an instance of the item within the collection. We can observe this more clearly with the following code:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<%@ Import namespace="System.Data" %>
<%@ Import namespace="BindingSample" %>
<asp:Repeater id="dataSetRepeater" Runat="server">
<ItemTemplate>
<%# ((DataRowView)Container.DataItem)["customerId"] %> -  
<%# ((DataRowView)Container.DataItem)["Name"] %> <br />
</ItemTemplate>   
<AlternatingItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "customerId") %> -  
<%# DataBinder.Eval(Container.DataItem, "Name") %> <br />
</AlternatingItemTemplate>                    
</asp:Repeater> 
<br><br>
<asp:Repeater id="collectionRepeater" Runat="server">
<ItemTemplate>
<%# ((Owner)Container.DataItem).OwnerId %> -  
<%# ((Owner)Container.DataItem).FirstName %> <br />
</ItemTemplate>    
<AlternatingItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "OwnerId") %> - 
<%# DataBinder.Eval(Container.DataItem, "FirstName") %> <br />
</AlternatingItemTemplate>        
</asp:Repeater>

In the first Repeater, we are binding to a DataSet, the ItemTemplate shows how to access values by casting DataItem to a DataRowView [5, 6], the AlternateItemTemplate will output the same information but through DataBinder.Eval [9, 10].

In the second Repeater, we bind to a custom collection. Again, the ItemTemplate shows how to cast DataItem to the right type and access the fields directly [18, 19] while the AlternateItemTemplate shows how the same is accomplished with DataBinder.Eval [22, 23].

In both cases, the ItemTemplate and AlternateItemTemplate will output the exact same information. The only difference is how the information is retrieved. DataBinder.Eval is far less performing, but has the benefit of being ignorant of the underlying structure, making it both quicker to develop and more likely to resist future changes. The goal here isn’t to discuss the merits of these approaches, but simply show what DataItem truly is in order to build a proper foundation of understanding.

Katrina Kaif The New Face of Lux

Posted by admin On March - 10 - 2010

Bolywood actresses Katrina Kaif has joined hands with celebrities Aishwarya Rai and Priyanka Chopra as the new brand ambassador for Lux and she thinks it is only a selected lot to have had the “honour”.

Katrina has been roped in as the face of the Lux Purple Lotus & Cream, a soap infused with anti-ageing properties.

“I don’t think every actress in Bollywood has been associated with Lux. A select few actresses, who they felt suited the brand right (have been associated with it) and they all have been actresses of great stature with wonderful careers and some wonderful work,” Katrina told IANS on Sunday (Feb 28).

“I am very honoured to join the group of people who have been with Lux over the years,” she added.

The new commercial has been shot in Bangkok and directed by Marco. While Katrina has been styled by fashion designer Rocky S for the ad, the music has been composed by trio Shankar Ehsaan Loy.

Actor Abhishek Bachchan also endorses Lux with wife Aishwarya.

jQuery Datagrid Script

Posted by admin On March - 10 - 2010

At end 3.0 (rc) version of jqGrid is out. This version is a major release, because I have totally rewrite the code for the methods without affecting the behavior of the plugin.
The grid is now compatible with jQuery 1.2.1, but in the example page I use 1.1.4 version of jQuery. The problem is that with 1.2.1 jqGrid has a little slowly behavior. I do not know why?
The example page is totally rewritten. Every example has a separate code for html and javascript. You can view this here.

This version fixes a lot of bugs relating to json data, formating, xml manipulation and add following features.

* The user can now manipulate the number of requested pages. This is done with adding a input box in the pager.
* I have added 4 methods – add, update, delete get row data. With these method we can manipulate the data at client side and of course a possibility to add local array data. See documentation for more information.
* Added is a method to load data only once from the server – loadonce flag in settings. After loading data we do all the manipulation at client side – sorting, scrolling ant etc. Note that in this case pager is disabled.
* Added is a new data type – local (against with xml and json). When this flag is set the grid expect data to be loaded locally via array.
* Now we can multi select rows. This can be done with only one flag multiselect. This feature can be used with server and local array data.
* For first time I introduce a sub grid. This feature can work only with xml data for now. The code and style for sub grid must be optimized and should be used with json too. See example page for more details.
* It is possible now to export the grid data to xml and json format. This is done with two new methods.
* A few new methods are added according to the new features – see documentation page for this.
* New theme of course
jqGrid is an Ajax-enabled JavaScript control that provides solutions for representing and manipulating tabular data on the web. Since the grid is a client-side solution loading data dynamically through Ajax callbacks, it can be integrated with any server-side technology, including PHP, ASP, Java Servlets, JSP, ColdFusion, and Perl.

jqGrid uses a jQuery Java Script Library and is written as plugin for that package. For more information on jQuery, please refer to the jQuery web site.
Demo: http://trirand.com/jqgrid/jqgrid.html
Download: http://www.trirand.com/jqgrid/jqGrid-3.4.4.zip
Source: http://www.trirand.com/blog/?p=13