Click here to Skip to main content
11,502,436 members (38,132 online)
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)



Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2015
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