Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Gridview
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id"
                                    ItemStyle-CssClass="ItemPixel" />
How to get all the values from this column of gridview in c#.
 
Binding grid using Datasource
 
ID
1
2
3
 
I want 1,2,3 in c# ON button click event
Posted 1-Feb-13 7:35am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try
string index = string.empty;
foreach(GridViewRow row in GridView1.Rows)
{
    index = index + "," + Convert.ToString(GridView1.Cells[0].Value);
}
return index,substring(0, index.Length - 2);
  Permalink  
v3
Comments
Member 9581488 at 1-Feb-13 13:50pm
   
GridView2.DataKeys[row.ID]
error : some invalid arg
Abhinav S at 1-Feb-13 14:06pm
   
Try now.
Member 9581488 at 1-Feb-13 14:08pm
   
thank you..Its working now.I thought we have similar kind of accessibility for gridview columns like we have for row.
Thank you!

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

  Print Answers RSS
0 OriginalGriff 490
1 Gihan Liyanage 338
2 ChauhanAjay 180
3 Vinay Mistry 160
4 Sergey Alexandrovich Kryukov 153
0 Sergey Alexandrovich Kryukov 9,011
1 OriginalGriff 7,941
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100