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

Help on Datagrid finding a template column control

RJN
Hi

I have a few template columns in my grid and each has a header template.
Within the header template I have got 2 controls, one is a link button
and other image. There is a sort command on each of the header columns
and an image which shows whether descending or ascending.

<asp:TemplateColumn HeaderText="Name">
<HeaderTemplate>
<asp:LinkButton ID="link1" CommandArgument="id" CommandName="Sort"
Runat="server">id</asp:LinkButton>
<asp:Image ID="imgId" runat="server" ImageUrl="asc.jpg"
Visible="false"></asp:Image>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblId" Text='<%#DataBinder.Eval(Container.DataItem
,"Id")%>'runat=server></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I have to show the image only on the column that is being sorted. How
can I get access to the image control which is within the header control
in the SortCommand Event some thing like FindControl("imgId"). I saw the
sender object lists only the columns which are within ItemTemplate and
not the HeaderTemplate. Can anyone help me out?

Regards

RJN


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
1 2277
I think you will have to use the OnItemCreated event to get hold of the
object
ListItemType.Header is not associated with OnItemDataBound

use a if statement to determine whether you have the header or not
if(e.Item.ItemType == ListItemType.Item)

{

ImageButton imgButton =
(ImageButton)e.Item.FindControl("MyImageButtonID") ;

imgButton.ImageUrl = "your url here";

}
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"RJN" <rj*@yahoo.com> wrote in message
news:#k**************@tk2msftngp13.phx.gbl...
Hi

I have a few template columns in my grid and each has a header template.
Within the header template I have got 2 controls, one is a link button
and other image. There is a sort command on each of the header columns
and an image which shows whether descending or ascending.

<asp:TemplateColumn HeaderText="Name">
<HeaderTemplate>
<asp:LinkButton ID="link1" CommandArgument="id" CommandName="Sort"
Runat="server">id</asp:LinkButton>
<asp:Image ID="imgId" runat="server" ImageUrl="asc.jpg"
Visible="false"></asp:Image>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblId" Text='<%#DataBinder.Eval(Container.DataItem
,"Id")%>'runat=server></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I have to show the image only on the column that is being sorted. How
can I get access to the image control which is within the header control
in the SortCommand Event some thing like FindControl("imgId"). I saw the
sender object lists only the columns which are within ItemTemplate and
not the HeaderTemplate. Can anyone help me out?

Regards

RJN


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2

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

Similar topics

4
by: Bruce Pullum | last post by:
I have a datagrid that I am using a DataView with. All works great for the sorting of the columns. However, after I sort the column, and then try and select a data row to edit, the row selected...
4
by: Richard Roche | last post by:
Is it possible to use a drop combo instead of a text box when using the EditCommand in the Datagrid? Many table columns are bound to 'lookup' tables, user's don't care about the foreign keys,...
0
by: trinitypete | last post by:
Fixed it, the first item received in the onItemBound event is the datagrid header, this doesn't contain the button. I just have to ensure that I only check the body. Pete. >-----Original...
2
by: damonf | last post by:
I'm currently trying to add an ASP hyperlink to a template column in a datagrid. The normal hyperlink column doesn't give me the ability to add attributes to the item. In my grid there are four...
2
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
4
by: Stephan Bour | last post by:
Hi, I have a datagrid databound to a SQL query. I'd like to allow editing of some columns but not all. Is there a way to turn off the conversion of the datagrid cells to textboxes for some columns...
6
by: Tim Meagher | last post by:
Can anyone help me figure out how to apply a stylesheet to a pushbutton defined in the asp:BoundColumn or asp:EditCommandColumn elements of a datagrid?
0
by: Sridhar | last post by:
Hi, I have a datagrid which contains some bound columns, some template columns. The template columns contain text box in one column, Hyperlink column in other column, dropdownlist in another...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.