|
| |
User Groups : Forums : SiteExperts : Microsoft .NET
: | View All Replies |  | | TomppiF on Nov 9, 2005 at 8:09:42 AM I found a solution myself I exchanged all the BoundColumns for TemplateColumns and added Labels to these. I then set the DataSource for them through the Text property, like this:
< asp:TemplateColumn HeaderText="Gender"> < ItemTemplate>
< asp:Label ID="lblGender" Runat="server" Text='< %#Convert.ToString(DataBinder.Eval(Container.DataItem,"Gender"))% >'> < /asp:Label>
< /ItemTemplate> < /asp:TemplateColumn>
This made it possible to programatically access the contents of a cell with the FindControl() method.
foreach(DataGridItem gridItem in DataGrid1.Items) { Label lblTemp = (Label)gridItem.FindControl("lblGender"); string Gender = lblTemp.Text; lblTemp.BackColor=Color.LightBlue; }
At least like this I don't have to use indexes. But if anyone has a different solution, with which it isn't necessary to create templatecolumns and labels, please don't hesitate to post it here.
Thank you.
| | View All Replies |
To respond to a discussion, you must first logon.
If you are not registered, please register yourself to become a member of the SiteExperts.community.
|