473,387 Members | 3,820 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.

EditCommandColumn ButtonType=PushButton CSS

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" UpdateText="Update"></asp:EditCommandColumn>

I want to change the way my buttons look.

Thank you
Maz.
Nov 16 '05 #1
5 4117
Hi Maz,

You cannot apply the css directly to the column in design view but what you
can do is use the ItemDataBound event of the DataGrid to set the cssclass
onto the button with code like this:

private void pricingRuleDataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item
||e.Item.ItemType==ListItemType.AlternatingItem
||e.Item.ItemType==ListItemType.EditItem)
{
((WebControl)e.Item.Cells[4].Controls[0]).CssClass = "button1";
}
}

This of course assumes that the button is in the fifth column of the grid.

--
Steve Willcock (MCSD for Microsoft.NET)
http://www.willcockconsulting.com/

"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:Ik*************@news04.bloor.is.net.cable.rog ers.com...
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" UpdateText="Update"></asp:EditCommandColumn>

I want to change the way my buttons look.

Thank you
Maz.

Nov 16 '05 #2
Thank you. I tried it and this is what I get.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:

Line 134: ||e.Item.ItemType==ListItemType.EditItem)
Line 135: {
Line 136: ((WebControl)e.Item.Cells[11].Controls[0]).CssClass =
"button1";
Line 137: }
Line 138:
Thanks
Maz.
"Steve Willcock" <st***@N-O-S-P-A-Mwillcockconsulting.com> wrote in message
news:cf*******************@news.demon.co.uk...
Hi Maz,

You cannot apply the css directly to the column in design view but what
you
can do is use the ItemDataBound event of the DataGrid to set the cssclass
onto the button with code like this:

private void pricingRuleDataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item
||e.Item.ItemType==ListItemType.AlternatingItem
||e.Item.ItemType==ListItemType.EditItem)
{
((WebControl)e.Item.Cells[4].Controls[0]).CssClass = "button1";
}
}

This of course assumes that the button is in the fifth column of the grid.

--
Steve Willcock (MCSD for Microsoft.NET)
http://www.willcockconsulting.com/

"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:Ik*************@news04.bloor.is.net.cable.rog ers.com...
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" UpdateText="Update"></asp:EditCommandColumn>

I want to change the way my buttons look.

Thank you
Maz.


Nov 16 '05 #3
Thanks I got it... I was pointing to the wrong cell.
"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:sz**********************@twister01.bloor.is.n et.cable.rogers.com...
Thank you. I tried it and this is what I get.

Exception Details: System.InvalidCastException: Specified cast is not
valid.

Source Error:

Line 134: ||e.Item.ItemType==ListItemType.EditItem)
Line 135: {
Line 136: ((WebControl)e.Item.Cells[11].Controls[0]).CssClass = "button1";
Line 137: }
Line 138:
Thanks
Maz.
"Steve Willcock" <st***@N-O-S-P-A-Mwillcockconsulting.com> wrote in
message news:cf*******************@news.demon.co.uk...
Hi Maz,

You cannot apply the css directly to the column in design view but what
you
can do is use the ItemDataBound event of the DataGrid to set the cssclass
onto the button with code like this:

private void pricingRuleDataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item
||e.Item.ItemType==ListItemType.AlternatingItem
||e.Item.ItemType==ListItemType.EditItem)
{
((WebControl)e.Item.Cells[4].Controls[0]).CssClass = "button1";
}
}

This of course assumes that the button is in the fifth column of the
grid.

--
Steve Willcock (MCSD for Microsoft.NET)
http://www.willcockconsulting.com/

"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:Ik*************@news04.bloor.is.net.cable.rog ers.com...
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" UpdateText="Update"></asp:EditCommandColumn>

I want to change the way my buttons look.

Thank you
Maz.



Nov 16 '05 #4
Sorry for one more question. Once the user clicks Edit is changes to Update
and Cancel. Howerver, I can not get my CSS to bind itself to Cancel as well
too. Any idea?
Thank you


"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:jB**********************@twister01.bloor.is.n et.cable.rogers.com...
Thanks I got it... I was pointing to the wrong cell.
"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:sz**********************@twister01.bloor.is.n et.cable.rogers.com...
Thank you. I tried it and this is what I get.

Exception Details: System.InvalidCastException: Specified cast is not
valid.

Source Error:

Line 134: ||e.Item.ItemType==ListItemType.EditItem)
Line 135: {
Line 136: ((WebControl)e.Item.Cells[11].Controls[0]).CssClass =
"button1";
Line 137: }
Line 138:
Thanks
Maz.
"Steve Willcock" <st***@N-O-S-P-A-Mwillcockconsulting.com> wrote in
message news:cf*******************@news.demon.co.uk...
Hi Maz,

You cannot apply the css directly to the column in design view but what
you
can do is use the ItemDataBound event of the DataGrid to set the
cssclass
onto the button with code like this:

private void pricingRuleDataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item
||e.Item.ItemType==ListItemType.AlternatingItem
||e.Item.ItemType==ListItemType.EditItem)
{
((WebControl)e.Item.Cells[4].Controls[0]).CssClass = "button1";
}
}

This of course assumes that the button is in the fifth column of the
grid.

--
Steve Willcock (MCSD for Microsoft.NET)
http://www.willcockconsulting.com/

"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:Ik*************@news04.bloor.is.net.cable.rog ers.com...
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" UpdateText="Update"></asp:EditCommandColumn>

I want to change the way my buttons look.

Thank you
Maz.



Nov 16 '05 #5
Er... not really sure about that one - I think you should be able to use the
same mechanism to do this - not sure why it wouldn't work.

Steve

"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:HG*********************@twister01.bloor.is.ne t.cable.rogers.com...
Sorry for one more question. Once the user clicks Edit is changes to Update and Cancel. Howerver, I can not get my CSS to bind itself to Cancel as well too. Any idea?
Thank you


"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:jB**********************@twister01.bloor.is.n et.cable.rogers.com...
Thanks I got it... I was pointing to the wrong cell.
"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:sz**********************@twister01.bloor.is.n et.cable.rogers.com...
Thank you. I tried it and this is what I get.

Exception Details: System.InvalidCastException: Specified cast is not
valid.

Source Error:

Line 134: ||e.Item.ItemType==ListItemType.EditItem)
Line 135: {
Line 136: ((WebControl)e.Item.Cells[11].Controls[0]).CssClass =
"button1";
Line 137: }
Line 138:
Thanks
Maz.
"Steve Willcock" <st***@N-O-S-P-A-Mwillcockconsulting.com> wrote in
message news:cf*******************@news.demon.co.uk...
Hi Maz,

You cannot apply the css directly to the column in design view but what you
can do is use the ItemDataBound event of the DataGrid to set the
cssclass
onto the button with code like this:

private void pricingRuleDataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item
||e.Item.ItemType==ListItemType.AlternatingItem
||e.Item.ItemType==ListItemType.EditItem)
{
((WebControl)e.Item.Cells[4].Controls[0]).CssClass = "button1";
}
}

This of course assumes that the button is in the fifth column of the
grid.

--
Steve Willcock (MCSD for Microsoft.NET)
http://www.willcockconsulting.com/

"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:Ik*************@news04.bloor.is.net.cable.rog ers.com...
> 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" UpdateText="Update"></asp:EditCommandColumn>
>
> I want to change the way my buttons look.
>
> Thank you
> Maz.
>
>



Nov 16 '05 #6

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

Similar topics

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>...
1
by: Mark | last post by:
I have two buttons in a DataGrid. If I leave the ButtonType = "LinkButton", the EditCommand and DeleteCommand events fire fine. If I change th ButtonType = "PushButton", the events do not fire. ...
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: John Mason | last post by:
Hi, I have a Datagrid control with an edit command column, which has a PushButton ButtonType. I am trying to apply formatting to the plain grey button, to make it look more appealing on...
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: 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:
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?
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
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.