Solved

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

Posted on 2015-02-06
2
56 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:jfellrath
2 Comments
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 500 total points
Comment Utility
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:jfellrath
Comment Utility
Thank you!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

728 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now