EditCommandColumn ButtonType=PushButton CSS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maziar Aflatoun

    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:EditComman dColumn ButtonType="Pus hButton" EditText="Edit"
    CancelText="Edi t" UpdateText="Upd ate"></asp:EditCommand Column>

    I want to change the way my buttons look.

    Thank you
    Maz.


  • Steve Willcock

    #2
    Re: EditCommandColu mn ButtonType=Push Button CSS

    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 pricingRuleData Grid_ItemDataBo und(object sender,
    System.Web.UI.W ebControls.Data GridItemEventAr gs e)
    {
    if(e.Item.ItemT ype==ListItemTy pe.Item
    ||e.Item.ItemTy pe==ListItemTyp e.AlternatingIt em
    ||e.Item.ItemTy pe==ListItemTyp e.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)


    "Maziar Aflatoun" <maz00@rogers.c om> wrote in message
    news:Ik7Tc.17$6 JQ.14@news04.bl oor.is.net.cabl e.rogers.com...[color=blue]
    > Hi everyone,
    >
    > Does anyone know how I can add a CSS (Ex. button1 ) to the following Edit
    > button is ASP .NET?
    >
    > <asp:EditComman dColumn ButtonType="Pus hButton" EditText="Edit"
    > CancelText="Edi t" UpdateText="Upd ate"></asp:EditCommand Column>
    >
    > I want to change the way my buttons look.
    >
    > Thank you
    > Maz.
    >
    >[/color]


    Comment

    • Maziar Aflatoun

      #3
      Re: EditCommandColu mn ButtonType=Push Button CSS

      Thank you. I tried it and this is what I get.

      Exception Details: System.InvalidC astException: Specified cast is not valid.

      Source Error:

      Line 134: ||e.Item.ItemTy pe==ListItemTyp e.EditItem)
      Line 135: {
      Line 136: ((WebControl)e. Item.Cells[11].Controls[0]).CssClass =
      "button1";
      Line 137: }
      Line 138:


      Thanks
      Maz.


      "Steve Willcock" <steve@N-O-S-P-A-Mwillcockconsul ting.com> wrote in message
      news:cfjbtt$nd0 $1$830fa17d@new s.demon.co.uk.. .[color=blue]
      > 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 pricingRuleData Grid_ItemDataBo und(object sender,
      > System.Web.UI.W ebControls.Data GridItemEventAr gs e)
      > {
      > if(e.Item.ItemT ype==ListItemTy pe.Item
      > ||e.Item.ItemTy pe==ListItemTyp e.AlternatingIt em
      > ||e.Item.ItemTy pe==ListItemTyp e.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" <maz00@rogers.c om> wrote in message
      > news:Ik7Tc.17$6 JQ.14@news04.bl oor.is.net.cabl e.rogers.com...[color=green]
      >> Hi everyone,
      >>
      >> Does anyone know how I can add a CSS (Ex. button1 ) to the following Edit
      >> button is ASP .NET?
      >>
      >> <asp:EditComman dColumn ButtonType="Pus hButton" EditText="Edit"
      >> CancelText="Edi t" UpdateText="Upd ate"></asp:EditCommand Column>
      >>
      >> I want to change the way my buttons look.
      >>
      >> Thank you
      >> Maz.
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Maziar Aflatoun

        #4
        Re: EditCommandColu mn ButtonType=Push Button CSS

        Thanks I got it... I was pointing to the wrong cell.


        "Maziar Aflatoun" <maz00@rogers.c om> wrote in message
        news:szpTc.1702 679$Ar.1238439@ twister01.bloor .is.net.cable.r ogers.com...[color=blue]
        > Thank you. I tried it and this is what I get.
        >
        > Exception Details: System.InvalidC astException: Specified cast is not
        > valid.
        >
        > Source Error:
        >
        > Line 134: ||e.Item.ItemTy pe==ListItemTyp e.EditItem)
        > Line 135: {
        > Line 136: ((WebControl)e. Item.Cells[11].Controls[0]).CssClass = "button1";
        > Line 137: }
        > Line 138:
        >
        >
        > Thanks
        > Maz.
        >
        >
        > "Steve Willcock" <steve@N-O-S-P-A-Mwillcockconsul ting.com> wrote in
        > message news:cfjbtt$nd0 $1$830fa17d@new s.demon.co.uk.. .[color=green]
        >> 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 pricingRuleData Grid_ItemDataBo und(object sender,
        >> System.Web.UI.W ebControls.Data GridItemEventAr gs e)
        >> {
        >> if(e.Item.ItemT ype==ListItemTy pe.Item
        >> ||e.Item.ItemTy pe==ListItemTyp e.AlternatingIt em
        >> ||e.Item.ItemTy pe==ListItemTyp e.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" <maz00@rogers.c om> wrote in message
        >> news:Ik7Tc.17$6 JQ.14@news04.bl oor.is.net.cabl e.rogers.com...[color=darkred]
        >>> Hi everyone,
        >>>
        >>> Does anyone know how I can add a CSS (Ex. button1 ) to the following
        >>> Edit
        >>> button is ASP .NET?
        >>>
        >>> <asp:EditComman dColumn ButtonType="Pus hButton" EditText="Edit"
        >>> CancelText="Edi t" UpdateText="Upd ate"></asp:EditCommand Column>
        >>>
        >>> I want to change the way my buttons look.
        >>>
        >>> Thank you
        >>> Maz.
        >>>
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Maziar Aflatoun

          #5
          Re: EditCommandColu mn ButtonType=Push Button CSS

          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" <maz00@rogers.c om> wrote in message
          news:jBpTc.1702 750$Ar.1157165@ twister01.bloor .is.net.cable.r ogers.com...[color=blue]
          > Thanks I got it... I was pointing to the wrong cell.
          >
          >
          > "Maziar Aflatoun" <maz00@rogers.c om> wrote in message
          > news:szpTc.1702 679$Ar.1238439@ twister01.bloor .is.net.cable.r ogers.com...[color=green]
          >> Thank you. I tried it and this is what I get.
          >>
          >> Exception Details: System.InvalidC astException: Specified cast is not
          >> valid.
          >>
          >> Source Error:
          >>
          >> Line 134: ||e.Item.ItemTy pe==ListItemTyp e.EditItem)
          >> Line 135: {
          >> Line 136: ((WebControl)e. Item.Cells[11].Controls[0]).CssClass =
          >> "button1";
          >> Line 137: }
          >> Line 138:
          >>
          >>
          >> Thanks
          >> Maz.
          >>
          >>
          >> "Steve Willcock" <steve@N-O-S-P-A-Mwillcockconsul ting.com> wrote in
          >> message news:cfjbtt$nd0 $1$830fa17d@new s.demon.co.uk.. .[color=darkred]
          >>> 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 pricingRuleData Grid_ItemDataBo und(object sender,
          >>> System.Web.UI.W ebControls.Data GridItemEventAr gs e)
          >>> {
          >>> if(e.Item.ItemT ype==ListItemTy pe.Item
          >>> ||e.Item.ItemTy pe==ListItemTyp e.AlternatingIt em
          >>> ||e.Item.ItemTy pe==ListItemTyp e.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" <maz00@rogers.c om> wrote in message
          >>> news:Ik7Tc.17$6 JQ.14@news04.bl oor.is.net.cabl e.rogers.com...
          >>>> Hi everyone,
          >>>>
          >>>> Does anyone know how I can add a CSS (Ex. button1 ) to the following
          >>>> Edit
          >>>> button is ASP .NET?
          >>>>
          >>>> <asp:EditComman dColumn ButtonType="Pus hButton" EditText="Edit"
          >>>> CancelText="Edi t" UpdateText="Upd ate"></asp:EditCommand Column>
          >>>>
          >>>> I want to change the way my buttons look.
          >>>>
          >>>> Thank you
          >>>> Maz.
          >>>>
          >>>>
          >>>
          >>>[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Steve Willcock

            #6
            Re: EditCommandColu mn ButtonType=Push Button CSS

            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" <maz00@rogers.c om> wrote in message
            news:HGpTc.1702 951$Ar.396075@t wister01.bloor. is.net.cable.ro gers.com...[color=blue]
            > Sorry for one more question. Once the user clicks Edit is changes to[/color]
            Update[color=blue]
            > and Cancel. Howerver, I can not get my CSS to bind itself to Cancel as[/color]
            well[color=blue]
            > too. Any idea?
            >
            >
            > Thank you
            >
            >
            >
            >
            > "Maziar Aflatoun" <maz00@rogers.c om> wrote in message
            > news:jBpTc.1702 750$Ar.1157165@ twister01.bloor .is.net.cable.r ogers.com...[color=green]
            > > Thanks I got it... I was pointing to the wrong cell.
            > >
            > >
            > > "Maziar Aflatoun" <maz00@rogers.c om> wrote in message
            > > news:szpTc.1702 679$Ar.1238439@ twister01.bloor .is.net.cable.r ogers.com...[color=darkred]
            > >> Thank you. I tried it and this is what I get.
            > >>
            > >> Exception Details: System.InvalidC astException: Specified cast is not
            > >> valid.
            > >>
            > >> Source Error:
            > >>
            > >> Line 134: ||e.Item.ItemTy pe==ListItemTyp e.EditItem)
            > >> Line 135: {
            > >> Line 136: ((WebControl)e. Item.Cells[11].Controls[0]).CssClass =
            > >> "button1";
            > >> Line 137: }
            > >> Line 138:
            > >>
            > >>
            > >> Thanks
            > >> Maz.
            > >>
            > >>
            > >> "Steve Willcock" <steve@N-O-S-P-A-Mwillcockconsul ting.com> wrote in
            > >> message news:cfjbtt$nd0 $1$830fa17d@new s.demon.co.uk.. .
            > >>> Hi Maz,
            > >>>
            > >>> You cannot apply the css directly to the column in design view but[/color][/color][/color]
            what[color=blue][color=green][color=darkred]
            > >>> you
            > >>> can do is use the ItemDataBound event of the DataGrid to set the
            > >>> cssclass
            > >>> onto the button with code like this:
            > >>>
            > >>> private void pricingRuleData Grid_ItemDataBo und(object sender,
            > >>> System.Web.UI.W ebControls.Data GridItemEventAr gs e)
            > >>> {
            > >>> if(e.Item.ItemT ype==ListItemTy pe.Item
            > >>> ||e.Item.ItemTy pe==ListItemTyp e.AlternatingIt em
            > >>> ||e.Item.ItemTy pe==ListItemTyp e.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" <maz00@rogers.c om> wrote in message
            > >>> news:Ik7Tc.17$6 JQ.14@news04.bl oor.is.net.cabl e.rogers.com...
            > >>>> Hi everyone,
            > >>>>
            > >>>> Does anyone know how I can add a CSS (Ex. button1 ) to the following
            > >>>> Edit
            > >>>> button is ASP .NET?
            > >>>>
            > >>>> <asp:EditComman dColumn ButtonType="Pus hButton" EditText="Edit"
            > >>>> CancelText="Edi t" UpdateText="Upd ate"></asp:EditCommand Column>
            > >>>>
            > >>>> I want to change the way my buttons look.
            > >>>>
            > >>>> Thank you
            > >>>> Maz.
            > >>>>
            > >>>>
            > >>>
            > >>>
            > >>
            > >>[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...