Solved

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

Posted on 2015-02-06
2
63 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
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:jfellrath
ID: 40748662
Thank you!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net - TypeInitializer Error 25 25
Problem to refer to value 8 45
Expression Evaluater 3 24
asp.net mvc5 6 11
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

816 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

9 Experts available now in Live!

Get 1:1 Help Now