Gridview Control In ASP.Net

0 comments

In ASP.Net 2.0 Datagrid control is being renamed as Gridview Control. But there are some differences in ASP.Net 2.0 Gridview control. 3 main differences are
ASP.Net 2.0 has introduced 3 new column fields:
1. Checkbox field
2. Image field
3. Command Field
Following is an example view of commonly used fields and their attributes of ASP.Net Gridview control:

code:html
------------------------------------------
<asp:GridView ID="GridView1" runat="server" AllowPaging="true" AutoGenerateColumns="false">

<Columns>

<asp:CheckBoxField DataField="" />

<asp:ImageField DataImageUrlField="">

</asp:ImageField>

<asp:BoundField DataField="" />

<asp:ButtonField DataTextField="" ButtonType="Link" />

<asp:HyperLinkField DataTextField="" NavigateUrl="" />

<asp:TemplateField>

<ItemTemplate>

<%#DataBinder.Eval(Container.DataItem, "")%>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "")%>'></asp:TextBox>

</EditItemTemplate>

</asp:TemplateField>

</Columns>

<PagerSettings Mode="Numeric" />

</asp:GridView>
----------------------------------------------------------------------------------
Generally Bound Field column is used to display the tabulated read only view of the data retrieved from the database. You can use SQL Database easily to bind the data stored in SQL database. Ms Access Database can also be used to save the small scale data and bind the data with Gridview Control.
For an easy setup to bind the data with Gridview control you can setAutoGenerateColumns="false" to display the fields retrieved from the SQL Query.
This will automatically display the read-only view of data retrieved and automatically renders the appropriate control such as checkbox for bit datatype fields having value in the form of 0/1 or true/false.
To customize the view of data you can use the Template field. Div layout or tablescan be used inside the ItemTemplate to generate the structured view of data retrieved from the database.

Code - C#
----------------------------------------------------
<%#DataBinder.Eval(Container.DataItem, "DATABASE FIELD NAME")%>
---------------------------------------------
Above syntax can be used to bind the retrieved field in ASP.Net 2.0 Gridview ItemTemplate control.

Shorten your URL with Goo.gl or Bit.ly in Asp.net using C#

0 comments

While building an e-commerce web application, I realized that every e-commerce site needs social media button on the product detail page so that visitors can share what they have found. Of course you can let them share an URL like:

(OOPS) in C#.net

0 comments
                                                                OOPS Concepts

Class:

 It is a collection of objects.

Object:

It is a real time entity.
An object can be considered a "thing" that can perform a set of related activities. The set of activities that the object performs defines the object's behavior. For example, the hand can grip something or a Student(object) can give the name or address. In pure OOP terms an object is an instance of a class

Interview Questions in ASP.NET,C#.NET,SQL Server,.NET Framework

1 comments


Difference between stored procedure and function

1) Procedure can return zero or n values whereas function can return one value which is mandatory.
2) Procedures can have input, output parameters for it whereas functions can have only input parameters.
3) Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
4) Functions can be called from procedure whereas procedures cannot be called from function.
5) Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
6) We can go for transaction management in procedure whereas we can't go in function.
7) Procedures cannot be utilized in a select statement whereas function can be embedded in a select statement.

Vikram Chandra Theme by BloggerThemes & NewWPThemes Sponsored by iBlogtoBlog