C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » DataGridView »

BINDING (System.Collections.Generic.List) TO GRIDVIEW


Posted Date: 18 Nov 2008    Resource Type: Code Snippets    Category: DataGridView
Author: bobMember Level: Gold    
Rating: 1 out of 5Points: 10



THIS EXAMPLES HELPS TOU TO BIND DATAGRID WITH System.Collections.Generic.List ARRAY

PLACE A DATAGRID IN THE DEFAULT.ASPX PAGE AND WRITE THE FOLLOWING CODE



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class classCric : System.Web.UI.Page
{
//this is class
public class cricket
{
private int no;
private string cname;
private string country;
// this is property
public int no1
{
get
{
return no;
}
set
{
no = value;
}
}
public string cname1
{
get
{
return cname;
}
set
{
cname = value;
}
}
public string country1
{
get
{
return country;
}
set
{
country = value;
}
}
public cricket(int no1, string cname1, string country1)
{
this.no = no1;
this.cname = cname1;
this.country = country1;
}

}//end of cricket class


protected void Page_Load(object sender, EventArgs e)
{
System.Collections.Generic.List<cricket> cric = new System.Collections.Generic.List<cricket>();
cric.Add(new cricket(1, "dhoni", "india"));
cric.Add(new cricket(1, "afridi", "pak"));
cric.Add(new cricket(1, "mindas", "sl"));
GridView1.DataSource = cric;
GridView1.DataBind();

}
}


Attachments

  • DATAGRID BINDING (22543-18543-DATAGRID.DOC)



  • Responses

    Author: Jasjit    30 Dec 2008Member Level: Bronze   Points : 0
    This coding is not working


    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    WWW.DOTNETMATERIAL9.BLOGSPOT.COM  .  List  .  GRIDVIEW  .  Binding  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Datagrid - Editing, Updating, Cancel, Selecting Rows
    Previous Resource: Printing Datagridview content in windows aplication using C#.net.
    Return to Discussion Resource Index
    Post New Resource
    Category: DataGridView


    Post resources and earn money!
     
    Related Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use