473,378 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

C#: Accessing Labels In Gridview

Good day guys!

I'm using c# as my code-behind (ascx.cs) and my environment is Visual Studio 2008.

the issue is, i can't get to access labels inside the gridview..

my gridview definition is:

<================================================= ===========
Expand|Select|Wrap|Line Numbers
  1.  <asp:GridView ID="commentsGrid" runat="server" DataSourceID="sqlDS" 
  2.     Width="810px" AutoGenerateColumns="False" Font-Names="Tahoma" 
  3.     Font-Size="X-Small" BorderStyle="None" GridLines="None" ShowHeader=False 
  4.     onrowdatabound="commentsGrid_RowDataBound" Visible="False" >
  5.         <Columns>
  6.             <asp:TemplateField>
  7.                <ItemTemplate>
  8.                     <asp:Label ID="user" runat="server" Text=<%# Eval("User") %>> </asp:Label>
  9.                     <br />
  10.                     <asp:Label ID="regDate" runat="server" Text=<%# String.Format("{0:dd-MMMM-yy}", Eval("REGDATE"))%> > </asp:Label>
  11.                     <br />
  12.                     <asp:Label ID="regTime" runat="server" Text=<%# String.Format("{0:HH:mm:ss}", Eval("REGTIME"))%>> </asp:Label>
  13.                     <br />
  14.                     <asp:Label ID="regUser" runat="server" Text=<%# Eval("REGISTER_USER")%> Visible=true> </asp:Label>
  15.                 </ItemTemplate>
  16.                 <ControlStyle CssClass="styleu6"></ControlStyle>
  17.             </asp:TemplateField>
  18.             <asp:BoundField  DataField="MESSAGE" SortExpression="MESSAGE" ControlStyle-CssClass="styleu7" ShowHeader="False">
  19.                 <ControlStyle CssClass="styleu7"></ControlStyle>
  20.             </asp:BoundField>
  21.  
  22.             <asp:CommandField ButtonType="Button" ShowDeleteButton="True" 
  23.                 ShowEditButton="True" />
  24.  
  25.         </Columns>
  26.     </asp:GridView>
  27.  
  28.  
================================================== ==========>

::wherein the datasourceid is an sql object..

in my RowDataBound(object sender, GridViewRowEventArgs e) method, I already tried using:


<================================================= ===========

((Label)e.Row.Cells[0].FindControl("message")).Text
((Label)e.Row[e.Row.RowIndex].FindControl("regUser")).Text

================================================== ==========>

but what i get is all NULL.

i'm really just a beginner in c# and so far i'm doing gud except for this issue.

please help!
Jul 29 '08 #1
0 1196

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Michael Kellogg | last post by:
I have a problem wherein a query that updates a GridView doesn't seem to really stay in sync with a label I have above the GridView. I have a GridView object that I'm updating with information...
0
by: hazz | last post by:
A treeview control should be able to select various aspx pages in the site. (using sitemap) One content page will have a gridview, accessed through a content place holder while another aspx page...
5
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc"...
0
by: Dom | last post by:
Hello This should work I know ... but.. with your help perhaps.. Trying to assign a 'selectparameter' to an objectdatasource nested within a gridview EditItemTemplate. When I try to access...
0
by: Mudassar | last post by:
I am facing a problem while accessing the gridview in nested gridview structure. Some time i found child gridview control but when i bind data to child gridview it doesnt
3
by: John | last post by:
Hi I have a hidden (visible=false) column on a gridview bound to a sql server table. I am trying to access the field as; For Each row As GridViewRow In grdEvents.Rows If row.RowType =...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
1
by: DMC | last post by:
Hi, I have enabled paging in my gridview control and am now trying to work out how to programmatically access it. With my gridview i have an "Add" button which adds a new row to the gridview and...
1
by: HockeyFan | last post by:
protected void gvAuthorizedSigners_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EmptyInsert") { odsAuthorizedSigners.Insert(); return; } if (e.CommandName...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.