Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to edit the style of the "Edit" column in a .NET gridview

Posted on 2015-02-06
2
68 Views
Last Modified: 2015-04-28
Hi all,

I have created a GridView on a .NET 2.0 (I know, I know...) web page that has an Edit command.  The Edit command, obviously, opens up the column with the "Update" and "Cancel" link buttons.  

The style that our office's web site uses makes the two link buttons appear really close together.  Does anyone know what sort of command/style I can use to either space them apart more or put a "|" between the two link buttons or what have you?  

Thanks,
Jamie
0
Comment
Question by:Jamie Fellrath
2 Comments
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 500 total points
ID: 40595370
Try this
http://forums.asp.net/t/1682829.aspx?Is+it+possible+to+change+css+of+a+specific+column+of+GridView+control+at+run+time+

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
    protected void btnShow_Click(object sender, EventArgs e)
    {
        grvEmployees.HeaderRow.Cells[0].CssClass = "viscol";
        foreach (GridViewRow row in grvEmployees.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
                row.Cells[0].CssClass = "viscol";
        }
    }

    protected void btnHide_Click(object sender, EventArgs e)
    {
        grvEmployees.HeaderRow.Cells[0].CssClass = "hiddencol";

        foreach (GridViewRow row in grvEmployees.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
                row.Cells[0].CssClass = "hiddencol";
        }
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Pager template example</title>
    <style type="text/css">
        .hiddencol
        {
            display: none;
        }
        .viscol
        {
            display: block;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="grvEmployees" runat="Server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False"
            AllowPaging="True">
            <Columns>
                <asp:BoundField HeaderText="ProductID" DataField="ProductID" />
                <asp:BoundField HeaderText="ProductName" DataField="ProductName" />
                <asp:BoundField HeaderText="UnitPrice" DataField="UnitPrice" />
            </Columns>
        </asp:GridView>
        <br />
        <asp:Button ID="btnShow" runat="server" Text="Show first column" OnClick="btnShow_Click" />&nbsp;
        <asp:Button ID="btnHide" runat="server" Text="Hide first column" OnClick="btnHide_Click" />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT [ProductID] ,[ProductName],[UnitPrice] FROM [dbo].[Products]"
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" />
    </div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:Jamie Fellrath
ID: 40748662
Thank you!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question