473,387 Members | 1,515 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,387 software developers and data experts.

Another topic about getting data from ItemTemplate in DataGrid

I've read the 1000's of topics about accessing the text contained in
ItemTemplates, but I'm still having a problem.

Here's an excerpt my ASPX code:

<ItemTemplate>
<asp:Label ID="lblAppliesTo" Runat="server">
<%# DataBinder.Eval(Container, "DataItem.Manufacturer") %>&nbsp;
<%# DataBinder.Eval(Container, "DataItem.Model") %>
</asp:Label>
</ItemTemplate>

Here's my codebehind:

Label lblAppliesTo =
(Label)e.Item.Cells[3].FindControl("lblAppliesTo");
string appliesTo = lblAppliesTo.Text;

The index is correct.
The page displays the data in the grid correctly upon page load.

Here's the funny part. The above code returns an empty string for
appliesTo, but I can set the text of the label in this method without a
hitch and display the changed value. It's like it found the control,
but won't give me the current text.

Any ideas?
thanks,
..brit

Nov 19 '05 #1
1 1135
The C# code above is located in the ItemCommand method.
..brit

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robert | last post by:
This is a repost from the other dotnet.csharp forum: I'm including a simple datagrid control on my web form. I have created a Dataview (reportListView) onto a data table to populate it. At its...
1
by: Juba | last post by:
Hello, I have the following code placed at my Page_Load event and after the Datagrid is binded, so it is not empty. The problem is that the variable isclass is always returning null and I am...
0
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format....
7
by: Mike P | last post by:
I am binding data to a datagrid, but there is 1 field that I need to use a separate query to populate. This is the field : <asp:TemplateColumn HeaderText="SIP Account/s" ItemStyle-Width="75px"...
0
by: Tim::.. | last post by:
I keep getting the following error on a dropdownlist control I have added to a datagrid! I have given the control the correct id and don't get any errors when conpiling the code but as soon as I try...
0
by: Tim::.. | last post by:
Why doesn't my onEditCommand work??? I don't get an error it just doesn't do the page redirect as requested... Thanks ...CODE.. Sub LinkButton_OnClick(ByVal sender As Object, ByVal e As...
0
by: Erik | last post by:
Why isn't my update method getting called? Pasted below is an aspx from a 1.1 application I'm working on. It has two textboxes and a button for inserting data into the database, and a datagrid...
0
by: ashwin | last post by:
I have a Data Grid to display employee names and codes. On clicking a button (outside the datagrid) I perform some calculations which sets the fields of other columns in the datagrid. The problem...
0
by: ashwin | last post by:
I have a Data Grid to display employee names and codes. On clicking a button (outside the datagrid) I perform some calculations which sets the fields of other columns in the datagrid. The problem...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.