Help: Change the Font Color of EditCommandColumn Edit, Update, Cancel buttons?

Hi, I'm trying to find a method for changing the the font color and sizes for the update, cancel, delete buttons of the EditCommandColumn of the DataGrid after clicking on the edit button.  My ButtonType for the EditCommandColumn is Button.

I was able to change the color of the the Edit button and the Delete button (Delete button prior to clicking on the Edit Button) by using an external CSS file and using the OnItemCreated="DataGridOnItemCreated". Under my fucntion, DataGridOnItemCreated, I accessed the two buttons using
protected void DataGridOnItemCreated(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
//Get the button
Button myEditButton = (Button)e.Item.Cells[0].Controls[0];
Button myDeleteButton = (Button)e.Item.Cells[12].Controls[0];
myEditButton.CssClass = "buttonEditStyle";
myDeleteButton.CssClass = "buttonDeleteStyle";
}
}

However I tried using
Button myEditButton = (Button)e.Item.Cells[0].Controls[1];
for the Update Button but index 1 was out of range and got and error.
Strange thing is I got the return type of the Controls corresponding to e.Item.Cells[0].Controls, where Cell[0] being the place of the EditCommandColumn, I got 6 returns of System.Web.UI.WebControls.Button types using the code below
foreach( Control ctl in e.Item.Cells[0].Controls)
{
lblDebug.Text = lblDebug.Text + " " + ctl.GetType().ToString();
}
I don't understand why I got back 6 Button types but I cannot access anything after Control[0].

Has anyone tried to change the font size or colors of those buttons yet or know of a way that will work?
Thanks for helping!

0
hon808
7/15/2003 9:44:08 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
927 Views

Similar Articles

[PageSpeed] 41

Did you find a solution?

I have the same problems as you..
0
MesterLars
8/22/2003 9:53:17 PM
In ItemCreated, watch for e.Item.Itemtype = ListItemType.EditItem and you should be able to access those controls
If e.Item.ItemType = ListItemType.EditItem then

' get update and cancel buttons and mess with their styles
End If

Jim


MS MVP ASP.NET [VC++/MFC emeritus]


Old Dog Learns New Tricks

Preferred programming language: cuneiform on clay tablets
0
JimRoss
8/22/2003 10:13:37 PM
before datagrid.databind , only e.Item.Cells[0].Controls[0] exists ,that is edit dataGridLinkButton

after datagrid.databind , both e.Item.Cells[0].Controls[0] (update ) and e.Item.Cells[0].Controls[1](cancel ) exist.
Please try again.
0
hjlee_tw
8/23/2003 2:57:14 AM
Reply:

Similar Artilces:

How to change the 'edit' button to 'Update'+'Cancel' button in Gridview
Hi all, I'm using a commandField 'edit' button in a Gridview which I hope to be changed to a 'update' and a 'cancel' button when the 'edit' button is pushed. My codes are as follow.  My problem is that I don't know what codes should be added to make the change I mentioned to happen. THanks a lot for your assistance. TOny<%@ Page Language="VB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><%@ Import Namespace="syste...

H: Cancel updating and keep in edit mode with Update and Cancel link buttons visible
I have an asp page with GridView control and datasource control (binding to a class). The gridview control has a RowUpdating event. Within the event, I check if the entered data is valid or not when it is in edit mode.  If the data is not valid, I set e.Cancel to true to cancel the updating to data source.When I run my page with a invalid case, it looks like that the gridview is still in edit mode (fields are still in textbox controls which can be edited), however, the link buttons are changed back to New and Edit buttons(I enabled add new row and edit for the gridview). I am not sure i...

Changing the font colour of the Edit button on a GridView control
Does anybody know if it is possible to change the colour and style of the Edit tag that appears at the beginning of each row on a GridView control? This is the link that users click to turn on the Edit mode. Similarly I would like to change the colour of the Update and Cancel tags when the GridView is in Edit mode.Many thanks.  Define the links yourself within the ItemTemplate and EditItemTemplate and you can do whatever you want to the links. This example shows how to change the font color to red two different ways: <asp:templatefield> <itemtemplate> <asp:lin...

How to change tree view's (web control) back color, font color and font size using CSS (Cascading Style Shteets)
Hi All, I have created tree view (web control) but i want to change all the properties of it, through single style sheet. Like all other controls (label, text box and combo box) it's not possible to change all the properties of treeview through single style sheet by including it to the contol ???? Please help........ MAITRAY. Sorry. No external css. but these attributes: DefaultStyle="background:#CCCCCC;border:solid 1px;color:black;font-size:8pt" HoverStyle="color:blue;font-name:Arial" SelectedStyle="c...

FormView control
When a user modifies the value in a textbox in a "EditTemplate" of the Form View, I would like the font color or back color of the text box to change - even before the update is submitted. How can I do that? Thanks. You can add an onchange event to your textbox: onchange="this.style.backgroundColor='yellow';" Or use the onkeyup event as well. You may need to add the handler for this if your textbox box is being created in the client side.Please mark as "answer" if this helped you in anyway. Thanks. here is how I did it:Protected Sub FirstName...

Help me update related controls after a control was updated.
I have nested UserControls on page. What I need to do is to update Profile UserControl after an item was deleted from the list of items. We are using AJAX (ATLAS) in our project. Which principle do I need to use to accomplish that task? How would you do it? Thank you. "A successful person is one who can lay a firm foundation with the bricks that others throw at him." http://www.russiangeek.com/ hello. well, can you explain this a little better?-- Regards,Luis Abreuemail: labreu_at_gmail.comEN blog:http://msmvps.com/blogs/luisabreu Luis Abreu: hello. well...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Signature font and color changes to message font and color
My first post. When I compose a message no matter what the signature font and color is set to, it changes to whatever the font and color is of the message. Is there a fix for this? I would ask my job's tech support but I wouldn't trust them to sit the right way on a toilet seat. -- doover ------------------------------------------------------------------------ doover, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, ...

Repeater Control: How to change change font color of <TR> or <TD>
I have a Repeater control which displays customer orders within an Html table. I need to dynamically change the font color of each <TR> row or <TD> table data tag. The color is stored in the same row I'm displaying, so retrieving the color value is not a problem. Am I on the right track here : My aspx page has the repeater control as follows: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource_Orders" OnDataBinding="Repeater1_DataBinding" OnItemDataBound="Repeater1_ItemDataBound"> and my aspx.cs has this so far (not much really): protec...

After hitting update on gridview, data changes but gridview still shows the update and cancel links for edited row
Really weird. I click the update link after I change the input data. I debug through it and it shows that the update is complete but then when OnRowUpdating function is done the update and cancel links are still there. What else do I need to do.. Here is the code. ASP:  <asp:GridView ID="OOWSecAuth" runat="server" AutoGenerateColumns="false" ShowFooter="true" AutoGenerateEditButton="true" OnRowEditing="OOWSecAuthEdit" OnRowUpdating="OOWSecAuthUpdate" ...

In .NET, font color changes in a string
In modern .NET do we still alter the changes to the font inline or with a class?Like:         if (strGoal.Equals(""))        {            QueryResult.Text = "You Must Enter a <font color='red'>Goal Name</font> before proceeding";            return;        } Or:        if (strGoal.Equals(""))&...

Disabled control
Hello, In the asp control like textbox/radio buttons/etc, you can disabled the control - Enabled="False". May I ask how do I change the disabled control font color? Now when it is disabled, the font color is light grayish. I want to change it to a more visible color. Please let me know how (if it can be done), thanks. it can't be done...

How do I change the text color on buttons? [Edit]
How can I change the text button color like in C# and IronPython with VCL in C++ Builder 2012? Here is the IronPython button OnClick message handler: [code] def Button1Click(self, sender, e): if self._button1.ForeColor == System.Drawing.Color.Blue: self._button1.ForeColor = System.Drawing.Color.Red self._button1.Text = "Red" else: self._button1.ForeColor = System.Drawing.Color.Blue self._button1.Text = "Blue" [/code] What about the background color, how is it set? If it's not possible, then please give the reference to documentation ...

Changing Update/Cancel Button Style
In a datagrid, I was able to change the style of the Edit button of the EditCommandColumn, but I have been trying to change the Update and Cancel buttons style but I can't.... here is the code I used for changing the style of the edit button: In the ItemDataBound Event: Dim btn As Button btn = e.Item.Cells(5).Controls(0) btn.CssClass = "BUTTONform" I tried to do the following for the Update/Cancel buttons: In the EditCommand event: Dim btn As Button btn = e.Item.Cells(5).Controls(...

Web resources about - Help: Change the Font Color of EditCommandColumn Edit, Update, Cancel buttons? - asp.net.presentation-controls

Resources last updated: 12/4/2015 2:03:38 AM