[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2015-02-06
2
Medium Priority
?
75 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
[X]
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
2 Comments
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

656 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