Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 30th, 2004, 04:45 AM
Authorized User
 
Join Date: Jun 2004
Posts: 54
Thanks: 0
Thanked 1 Time in 1 Post
Default How to change look n feel of button in Datagrid

Hi,

I am using datagrid in my asp.net web application as it gives me lots of option for formatting and changing it's layout and make it attractive.
But I could not format a Button added through ButtonColumn. Can anyone tell me how, I can change look and feel of a button in datagrid as we can do it with datagrid.



Vinod Pawar
Software Developer
India
__________________
Vinod Pawar
United States
 
Old August 30th, 2004, 07:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You could try using CSS.

 
Old August 30th, 2004, 01:07 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

dont think about your grid ...
every webcontrol has two main properties for working with its CSS
1-Style
2-CssClass

--------------------------------------------
Mehdi.:)
 
Old August 30th, 2004, 11:04 PM
Authorized User
 
Join Date: Jun 2004
Posts: 54
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks for reply, but still it does not work. If I put cssStyle explicitly it raises exception and if I use ItemStyle-CssClass it formats that particular cell which is holding this push button.

here I am pasting my code could you please give me what exactly I should you and where should I put either style or CssClass in ButtonColumn

<asp:DataGrid id="dgUsers" runat="server" OnItemCommand="dgUsers_ItemCommand" AutoGenerateColumns="False" DataKeyField="ID">
    <Columns>
        <asp:ButtonColumn Text="Block" ButtonType="PushButton" CommandName="Select"></asp:ButtonColumn>
    </Columns>
</asp:DataGrid>

Vinod Pawar
Software Developer
India
 
Old August 31st, 2004, 11:27 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think its better not to use ButtonColumn,
you could also use ItemTemplate and put a button and change the CssClass of the button(and also set the CommandName of this button)
although its practical to change your ButtonColumn somewhere in the codebehind
(but if I were you I'd use ItemTemplate due to this situation)
HtH.


--------------------------------------------
Mehdi.:)
 
Old September 1st, 2004, 10:00 AM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I agree with Mehdi's suggesion. It will be good idea not to use buttoncolumn in this situation. You can try using the following code snippet.


<asp:datagrid.....>
  <columns>
    <asp:templatecolumn .....>
      <headerstyle ....></headerstyle>
      <itemstyle></itemstyle>
      <itemtemplate>
        <asp:imagebutton cssclass="xx" commandname="yy" commandargument="zz"></asp:imagebutton>
      </itemtemplate>
    </asp:templatecolumn>
  </columns>
</asp:datagrid>

You use style the button the way you want it in this way. You can use the datagrid's ItemCommand event to capture the click event of the button.






Similar Threads
Thread Thread Starter Forum Replies Last Post
button command for page change Jonas Access 5 June 6th, 2007 11:39 AM
Change onclick of a button me_zeta HTML Code Clinic 1 November 20th, 2006 10:34 AM
How to change appearance of radio button BigBud Javascript How-To 3 March 22nd, 2005 10:34 AM
change class on browse button! MichaelTJ .NET Web Services 0 November 11th, 2003 11:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.