Wednesday, August 6, 2014

how to use GridView in asp.net

GridView example: how to use GridView in asp.net 

gridview is a very important control in asp.net. gridview is mainly uses for display tabular data. it also can edit, update, insert data. you can use it for various requirements. this can help you to display and format tabular data very fastest way. we can format the gridview's nearly all parts as example header, row, alternate row, pager etc. even we can place insert,edit,delete button for each row.

in this simple example we create a default formatted gridview. we also create a sqldatasource control populate the data source by a simple database query. we fetch data from northwind database customer table. finally we populate gridview by that sqldatasource. we set the gridview sorting, paging, auto generate columns true. so sorting, paging, columns names facility are created without much more coding. 
GridViewHowToUse.aspx


 

<%@ Page Language="C#" %>

            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="CustomerID" 
            DataSourceID="SqlDataSource1>
            
                                    SortExpression="CustomerID" />
                                    SortExpression="CompanyName" />
                                    SortExpression="ContactName" />
                                    SortExpression="ContactTitle" />
                                    SortExpression="Address" />
                
                                    SortExpression="Region" />
                                    SortExpression="PostalCode" />
                                    SortExpression="Country" />
                
                
            
   
            
       ConnectionString="<%$ ConnectionStrings:AppConnectionString1 %>" 
            SelectCommand="SELECT * FROM [Customers]">

If you are searching life partner. your searching end with kpmarriage.com. now kpmarriage.com offer free matrimonial website which offer free message, free chat, free view contact information. so register here : kpmarriage.com- Free matrimonial website