Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public void  DVD()
        {
           // ListItem ltim = new ListItem();
            List<string> lts = new List<string>();
 
            lts.Add("Name");
            lts.Add("Size");
            lts.Add("brand Name");
            lts.Insert(1, "SONY");
            lts.Insert(1, "Moserber");
            lts.Insert(1, "DVD");
            lts.Insert(2, "10MB");
            lts.Insert(2, "20MB");
            lts.Insert(2, "50MB");
 
            Griddata.DataSource = lts;
            Griddata.DataBind();
             
          
 

            
        
            }
Hi Friend ,

I tried like Above,

But i want display the list values like below into grid view.

Name Size brand
Sony 10MB qw
moserb 50MB e3
DVD 20MB qw3
Posted
Updated 25-Dec-12 19:55pm
v3
Comments
Mohd. Mukhtar 26-Dec-12 1:33am    
What have you tried so for??

No, we won't give you solution.. We can't work out for you like this.. You should try it by yourself.. If you got stuck somewhere, you can certainly come here.. But don't ask directly for code..
-Krunal R.
 
Share this answer
 
Think yourself about your problem. You have 3 columns, then you need to store the data in 3 column format. You can try:

C#
DataTable dt = new DataTable();
dt.Columns.Add("Name",typeof(string));
dt.Columns.Add("Size",typeof(string));
dt.Columns.Add("Brand",typeof(string));


Now add as many rows as you like:

C#
//Add the data in Name,Size,Brand Name format to the DataTable
dt.Rows.Add("1","10MB","SONY");
dt.Rows.Add("2","20MB","MOSERBAER");
dt.Rows.Add("3","30MB","HP");


Then bind the gridview:

C#
Griddata.DataSource = dt.DefaultView;
Griddata.DataBind();
 
Share this answer
 
v2
Comments
Arul R Ece 26-Dec-12 3:49am    
Hello man,

I know using data table.but my question is can we able do this using list OR
Array list
Zafar Sultan 26-Dec-12 4:26am    
No man, you did not say anywhere you need this to be done using only "ArrayList" or "List". Now, regarding your requirement, Create a class, three properties(Name,Size,Brand Name), create an object for every new row and then store this object in an IList. Bind your gridview with this IList. Refer to this link:

http://www.switchonthecode.com/tutorials/csharp-tutorial-binding-a-datagridview-to-a-collection

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900