C# : Tutorial of Asp.net with c# and example

Example and code about windows application, web application, SQL, C#, WPF etc which is helpful to developer and programer.

Search This Blog

Asp.net : What is ListView in asp.net and how it is use for binding Data?

♠ Posted by uvesh in

Definition of ListView and use of List view


ASP.NET have a new data binding control named the ListView. ASP.NET already has a number of  data bind controls. It may be more then 10 databinding control. ListView literally replace all other data binding controls in ASP.NET.

 ListView Control easy very easy for databinding. ListView control makes data binding easier than previous controls. It has default included styling with CSS, more flexible paging, and sorting, inserting, deleting, and updating features and many more.

The ASP.NET ListView control enables us to bind to data items that are returned from a data source and present  them to end user.

You can display data in pages so there is also load balancing at end user even there is large amount of data because of paging user no need wait for load data.
You can display items individually, or you can group them.

The ListView control displays data in a format that you define by using templates and styles.
It is useful for data in any repeating structure, similar to the DataList and Repeater controls.

However, unlike those controls, with the ListView control you can enable users to edit, insert, and delete data,and to sort and page data, all without code.


Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

C# : comment in asp.net or c sharp and use of it and short cut key for do comment

♠ Posted by uvesh in ,

How to comment code in asp.net?


Comment code in asp.net page as follow:


<%write comment here%>

Shortcut key for do comment in aspx page in asp.net as follow:


CTRL + K, CTRL + C For Make comment selected text.

CTRL + K,CTRL + U For Remove  comment of selected text.

Do comment in aspx.cs(code behind) page in asp.net as follow:

//comment  can write here

advantage of comment or use of comment as follow:


  • Removed at compile-time
  • Doesn't increase size of markup
  • You can even optimize with them







Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

C#: how to bind data in repeater control in asp.net? and example of repeater with c# code


What is Repeater Control?



Repeater Control is a control of asp.net which is used to display the data which is daynamic and repeatedly change collection of record


How to work repeater control of asp.net?

The Repeater control works by looping through the records in your data source and then repeating the rendering of
it’s templates called item template.
Repeater control contains different types of template fields those are

1) itemTemplate
2) AlternatingitemTemplate
3) HeaderTemplate
4) FooterTemplate
5) SeperatorTemplate


what is use of ItemTemplate in repeater control of asp.net?

ItemTemplate defines how the each item is rendered from dataBase collection.


what is use of AlternatingItemTemplate in repeater control of asp.net?


AlternatingItemTemplates is used to change the background color and styles of AlternatingItems in DataBase collection


what is use of HeaderTemplate in repeater control of asp.net?


HeaderTemplate is used to display Header text for DataSource collection and apply different styles for header text.


what is use of FooterTemplate in repeater control of asp.net?

FooterTemplate is used to display footer element for Data collection


what is use of SeparatorTemplate in repeater control of asp.net?

SeparatorTemplate will determine separator element which separates each Item in Item collection. Usually, SeparateTemplate will be <br> html tag or <hr> html tag.


How to Design of repeater control?


<asp:Repeater ID="Reptrsexample" runat="server">
<HeaderTemplate>
<table >
<tr >
<td colspan="2">
<b>header</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr >
<td>
<table>
<tr>
<td>
data:
<asp:Label ID="lblSubject" runat="server" Text='<%#Eval("field_name") %>' Font-Bold="true"/>
</td>
</tr>
</table>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>


How to Bind data in repeater by use of C#?

Import following name space

using System;
using System.Data;
using System.Data.SqlClient;


protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindRepeaterData();
}
}


protected void BindRepeaterData()
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from Repeater_Table", con);
DataSet ds = new DataSet();
SqlDataAdapter dadp = new SqlDataAdapter(cmd);
dadp.Fill(ds);
Reptrsexample.DataSource = ds;
Reptrsexample.DataBind();
con.Close();
}



Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/
 

Asp.Net Master Page Tutorial

♠ Posted by uvesh in ,


What Is Master Page in Asp.Net and How To create master page in Asp.Net



What Is Asp.Net master page?


In Web site development with Asp.Net, the master page is a feature that enables you to define common structure and interface markup elements for your web Site, including headers, footers, style definitions, or navigation bars. The master page can be shared by any of the pages in your Web site, called the content page, and removes need to duplicate code for shared elements within your Web site.

For instance, if you would like to display a standard header and footer in each page of your website, then you can generate the standard header and footer in a Master Page. That’s how powerful a master page is to handle multiple forms and is easier to maintain throughout what the website looks like. Take note, the ID attribute uniquely identifies the placeholder, allowing you to put more than one placeholder in a master page.

How to Create Master Page in Asp.Net?


To start - open your Visual Studio 2008, File and choose New Web Site, choose C#.

Choose ASP.NET Empty Web Site. Make the default File System; you can change the file directory of your file. Just simply browse and name your folder where your file is being saved and click Ok.





Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

User Control:How do i create user define control in asp.net c#

♠ Posted by uvesh in


How use Userdefine Control in Asp.Net



For create asp.net user define control using c# following step perform

Definition of UserControl in Asp.Net :

In Asp.Net Web server controls , you can create your own custom, reusable controls using following step. These controls are called user controls.

A user control is a kind of composite control that works much like an ASP.NET other server control . you can add existing Web server controls and markup to a user control, and define properties and methods for the control. You can then embed them in ASP.NET Web pages like same as other server control.




Start Visual Studio 2005.

File -New-Project Type Visual C#.



Step 1: Adding a user control to the web site

Adding a user control to your solution is real simple. You just have to right click your solution and click Add New Item; then from the dialog window click Web User Control and name the control YourControl.ascx.




Step 2: Adding the ASP.NET controls to YOURControl.ascx

As mentioned earlier this user control will merely consist of a GridView and a SqlDataSource ASP.NET server controls.
Before we go ahead and add our controls to the user control, notice that the Page directive is not used for our user control, and that it has been replaced with the Control directive.





If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

SQL Connection: Very Easy Code For SQL Connection by C# and Asp.Net

♠ Posted by uvesh in


How To make sql connection using C# Asp.net

The first of all need to do when interacting with a data base is to create a connection. It Microsoft SQL Server is a relational database management system developed by Microsoft.
Manages all of the low level logic associated with the specific database protocols. In code is instantiate the connection object, open the connection, and then close the connection when you are done. Because of the way that other classes in ADO.NET are built, sometimes you don't even have to do that much work.

Although working with connections is very easy, you need to understand connections in order to make the right decisions when coding your data access routines. Understand that a connection is a valuable resource. 

Following code write down in code behind page (aspx.cs page) For import Class Library of .net

using System.Data.SqlClient;


Following code write down in code behind page (aspx.cs page) For make connection 


SqlConnection myConnection = new SqlConnection("user id=username;" + 
                                       "password=password;server=serverurl;" + 
                                       "Trusted_Connection=yes;" + 
                                       "database=database; " + 

                                       "connection timeout=30");



This is the last part of getting connected and is simply executed by the following (remember to make sure your connection has a connection string first):

SqlConnection.Open()

This code put in Try Catch because this function may be throw error so try catch is usefull to handle error.

try
{
    myConnection.Open();
}
catch(Exception e)
{

    Console.WriteLine(e.ToString());
}



If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

Features of c# or advantage of c#


By This Article We Explain Features of C# 

  1. Modern

  2. Object oriented

  3. Type safe

  4. Version able

  5. consistent

  6. compatible

  7. flexible



1.    Modern : It supports, Automatic garbage collection, modern approach to debugging, rich intrinsic model for error handling, decimal data type for financial.

  1. Object :  It supports object-oriented system, namely Encapsulation, Inheritance and Polymorphism.
  1. Type-Safe :
                                                               i.      Type safety promotes robust programs, C# incorporates a number of type-safe measures.
                                                             ii.      All dynamically allocated object and arrays are initialized to zero.
                                                            iii.      Use of any uninitialized variables produces an error message by the compilers
                                                            iv.      Access to array are range checked and warned if it  goes out-of-bounds.
                                                             v.      C# does not permit unsafe casts.
                                                            vi.      C# enforces overflow checking in arithmetic’s operation.
                                                          vii.      Reference parameters that are passed are type-safe.
                                                         viii.      C# supports automatic garbage collection.

  1. Version able :  Making new versions of software modules work with the existing  applications is known as versioning with the help of new and override keywords, With this support, a programmer can guarantee that his new class library will maintain binary compatibility with the existing client application.

  1. Consistent : It supports an unified type system which eliminates the problem of varying ranges of integer types. All types are treated as object and developers can extend the type system simply and easily.

  1. Compatible :   C# enforce the .NET common language requirement and therefore allows interoperation with other .NET language.
C# Advantage





If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/