473,513 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3694
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
4282
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
1795
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
924
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
4146
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
1571
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
262
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
1020
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
1225
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
1286
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
7166
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
7534
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...
1
5094
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3236
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
459
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.