locked
Design For My Gridview RRS feed

  • Question

  • User2033107836 posted

    Hello

    See the below

    Friday, November 4, 2016 4:42 PM

Answers

  • User-1716253493 posted

    Try this

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            foreach(TableCell cell in e.Row.Cells)
            {
                cell.BorderColor = System.Drawing.Color.Black;
                cell.BorderWidth = new Unit(2);
                cell.BorderStyle = BorderStyle.Solid;
            }
        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 5, 2016 12:52 PM

All replies

  • User-2010311731 posted

    From what I am seeing, you want to hide the headers and right-align some columns.  Here is a quick sample...

    <asp:GridView ID="GridView1"
                  runat="server"
                  ShowHeader="false">
      <Columns>
        <asp:BoundField DataField="somefield"
                        ItemStyle-HorizontalAlign="Right"/>
      </Columns>
    </asp:GridView>

    Matt

    Friday, November 4, 2016 5:04 PM
  • User2033107836 posted

    no no 

    i want to design row and column width 2px and black

    how to do so

    Friday, November 4, 2016 5:09 PM
  • User475983607 posted

    asp.ambur

    no no 

    i want to design row and column width 2px and black

    how to do so

    Right click on the GridView in Visual Studio's Design View and select Properties.  In the properties window find BorderColor, BorderStyle, and BorderWidth.  Set them as you like.

    Also you might consider spending some time on MSDN reading about the GridView.

    https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview(v=vs.110).aspx

    You can also find many tutorials on this site by clicking the "Learn" link above.

    Friday, November 4, 2016 5:15 PM
  • User2033107836 posted

    i tried the same bit its not showing column black and row it shows only outer gridview 

    Friday, November 4, 2016 5:28 PM
  • User475983607 posted

    i tried the same bit its not showing column black and row it shows only outer gridview 

    See the RowStyle property.

    You really need to take a few minutes to read the docs...

    Friday, November 4, 2016 6:04 PM
  • User2033107836 posted

    row style worked

    but for each column how to set same?

    Friday, November 4, 2016 6:18 PM
  • User475983607 posted

    row style worked

    but for each column how to set same?

    Read the docs...

    Friday, November 4, 2016 6:21 PM
  • User2033107836 posted

    almost got it please give me idea to make column border color and width

    Friday, November 4, 2016 6:26 PM
  • User-2010311731 posted

    The best advice for a quick fix... assuming you are using Visual Studio, open your page in Design View.  Click on your grid and click the right-pointing arrow on the top-right corner of your grid, and select Auto-Format.  This will give you a selection of formats that you can choose from.

    Matt

    Friday, November 4, 2016 7:33 PM
  • User-1716253493 posted

    Try this

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            foreach(TableCell cell in e.Row.Cells)
            {
                cell.BorderColor = System.Drawing.Color.Black;
                cell.BorderWidth = new Unit(2);
                cell.BorderStyle = BorderStyle.Solid;
            }
        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 5, 2016 12:52 PM