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

Applying CSS to asp:EditCommandColumn

I'm have a datagrid with 2 buttons Edit and Delete.

<asp:EditCommandColumn ButtonType="PushButton" EditText="Edit"
CancelText="Cancel" UpdateText="Update"></asp:EditCommandColumn>
<asp:ButtonColumn ButtonType="PushButton" Text="Delete"
CommandName="Delete"></asp:ButtonColumn>
Once you click Edit it changes in Edit and Cancel. I like to apply CSS to
my buttons. I got it to work for Edit and Delete. However, I'm having
problem with Cancel? Any idea?

((WebControl)e.Item.Cells[12].Controls[0]).CssClass = "button1";
((WebControl)e.Item.Cells[13].Controls[0]).CssClass = "button1";

How would I apply this css "button1" to my once Edit clicked state?

Thank you
Maziar A.

Jul 21 '05 #1
1 3680
Hi,
I assume you are setting the CssClass in the ItemDataBound event. If so:
when the current item being rendered is of type EditItem then, set the
CssClass for both the controls in the edit command column. The code might
look like this:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
((WebControl)e.Item.Cells[12].Controls[0]).CssClass = "button1";
((WebControl)e.Item.Cells[13].Controls[0]).CssClass = "button1";
}
else if (e.Item.ItemType == ListItemType.EditItem)
{
// Controls[0] is Update
((WebControl)e.Item.Cells[12].Controls[0]).CssClass = "button1";
// Controls[1] is Cancel
((WebControl)e.Item.Cells[12].Controls[1]).CssClass = "button1";
}

Hope this helps.

"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:cL*********************@twister01.bloor.is.ne t.cable.rogers.com...
I'm have a datagrid with 2 buttons Edit and Delete.

<asp:EditCommandColumn ButtonType="PushButton" EditText="Edit"
CancelText="Cancel" UpdateText="Update"></asp:EditCommandColumn>
<asp:ButtonColumn ButtonType="PushButton" Text="Delete"
CommandName="Delete"></asp:ButtonColumn>
Once you click Edit it changes in Edit and Cancel. I like to apply CSS to
my buttons. I got it to work for Edit and Delete. However, I'm having
problem with Cancel? Any idea?

((WebControl)e.Item.Cells[12].Controls[0]).CssClass = "button1";
((WebControl)e.Item.Cells[13].Controls[0]).CssClass = "button1";

How would I apply this css "button1" to my once Edit clicked state?

Thank you
Maziar A.


Jul 21 '05 #2

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

Similar topics

1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
1
by: angus | last post by:
Dear All, I am using VB.net It is found that the <asp:EditCommandColumn/> wouldn't fired an event for OnEditCommand If pushbutton has been used: that is:
0
by: Maziar Aflatoun | last post by:
Hi everyone, Does anyone know how I can add a CSS (Ex. button1 ) to the following Edit button is ASP .NET? <asp:EditCommandColumn ButtonType="PushButton" EditText="Edit" CancelText="Edit"...
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?
2
by: Craig G | last post by:
is it possible to apply a style to the button? so far i cant work out how tried this but it wont work <asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" CancelText="Cancel"...
1
by: Maziar Aflatoun | last post by:
I'm have a datagrid with 2 buttons Edit and Delete. <asp:EditCommandColumn ButtonType="PushButton" EditText="Edit" CancelText="Cancel" UpdateText="Update"></asp:EditCommandColumn>...
0
by: CharlesA | last post by:
I've got this onn the left of my datagrid <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" HeaderText="Edit" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn> and...
0
by: slemen | last post by:
Hi, The DataGrid aps:EditCommandColumn when used with column templates created programmatically does not trigger the _Edit subroutine in code. The ASP:Datagrid definition is below (1), the...
0
by: slemen | last post by:
Hi, The asp:EditCommandColumn template does not fire the _edit sutboutine when the edit command column buttons are clicked. I get a Page Cannot Be Displayed page error instead. My (ASP 1.1)...
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...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.