ASP.NET - Gridview Records as Bold font

Asked By Krishna T on 26-Jun-12 08:22 AM
Earn up to 10 extra points for answering this tough question.
Hi,

I need to make One Column Records in the gridview as Bold. Can you give me solution?
[)ia6l0 iii replied to Krishna T on 26-Jun-12 09:23 AM
Style the cell in the column 1 with the RowDataBound Event of the gridview. 

See the following example, where the cell[0] in each row, which is column1, is set to appear Bold. 

protected void Employees_RowDataBound(object sender, GridViewRowEventArgs e)
{
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].Font.Bold = true;    
        }
}


Hope this helps.

Jitendra Faye replied to Krishna T on 26-Jun-12 09:34 AM
Use this code-

<asp:TemplateField  ItemStyle-Font-Bold ="true">
          <ItemTemplate>
            <asp:Label ID="lblID" runat="server" Text='<%# Eval("id") %>'></asp:Label>
          </ItemTemplate>
 </asp:TemplateField>
Vikram Singh Saini replied to Krishna T on 26-Jun-12 12:21 PM
If it is boundfiled and you want to make it's items bold you can write:

 <Columns>
          <asp:BoundField HeaderText="Adm. no" DataField="AdmNo" ItemStyle-Font-Bold="true" />

      . . . . . . . .

Ravi Maurya replied to Krishna T on 26-Jun-12 12:43 PM
If you want to make BoundField value as bold than you can simply make it as 

<asp:BoundField DataField="CategoryName" HeaderText="Categories" ItemStyle-Font-Bold="true"/>

Hope this might help you.
DL M replied to Krishna T on 26-Jun-12 12:56 PM
Use this code
---------------
protected void GridView1_DataBound(object sender, EventArgs e)
{
      GridView1.Rows[0].Style.Add(HtmlTextWriterStyle.FontWeight, "Bold");
}

If you need to make selectedrow bold,

<SelectedRowStyle ForeColor="White" Font-Bold="True"
       BackColor="#738A9C"></SelectedRowStyle>

If you need to make a particular row bold,

gridViewDeleg.Rows[3].Font.Bold = true;
Chintan Vaghela replied to Krishna T on 27-Jun-12 01:32 AM

Hi Frndz,

 

Functionality:  bold Gridview Row based on Condition

 

 

To achieve this task,

 

Added one hidden filed to  Item Template for store read/Unread value

 

<ItemTemplate>

          <asp:HiddenField ID="MilestoneID" runat="server" Value="'<%#Eval("FlagReadUnread") %>" />

          </ItemTemplate>

 

Now get this hidden filed value in rowdataound event and check this hidded field value

 

Added RowDatabound event and set row font bold as following way

 

 

 

Full Logic   :

 

 

protected void GrvMfDetails_RowDataBound(object sender, GridViewRowEventArgs e)

    {

    if (e.Row.RowType == DataControlRowType.DataRow)

    {

      HiddenField hdf = (HiddenField)e.Row.FindControl("MilestoneID");

 

      if (hdf.Value == "read")

      {

      e.Row.Font.Bold = true;

      }

    }

 

}

 

 

 

Hope this helpful!

Thanks

Chintan Vaghela replied to Krishna T on 27-Jun-12 02:08 AM

Hi Frndz,

 

Functionality:  bold Gridview Column  based on Condition

 

 

To achieve this task,

 

Added one hidden filed to  Item Template for store read/Unread value

 

<asp:TemplateField HeaderText="Message">

          <ItemTemplate>

            <asp:HiddenField ID="hdfMessageStatus" runat="server" Value='<%# Eval("Status") %>' />

            <asp:Label ID="lblMessage" runat="server" Text='<%# Eval("Message") %>'></asp:Label>

          </ItemTemplate>

        </asp:TemplateField>

 

 

Now get this hidden filed value in rowdataound event and check this hidded field value

 

Added RowDatabound event and set row font bold as following way

 

 

 

Full Logic   :

 

 

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

    {

      if (e.Row.RowType == DataControlRowType.DataRow)

      {

        HiddenField hdfMessageStatus = (HiddenField)e.Row.FindControl("hdfMessageStatus");

 

        Label lblMessage = (Label)e.Row.FindControl("lblMessage");

 

        if (hdfMessageStatus.Value == "read")

        {

          // Take Item Template then Find Control value and assign to Bold

          lblMessage.Font.Bold = true;

          // Take Bound Column then find Position of Bound filed value and set to Bold

          e.Row.Cells[5].Font.Bold = true;

        }

      }

} 

 

 

Hope this helpful!

Thanks

RAJASEKHAR RAJENDRAN replied to Krishna T on 28-Jun-12 02:58 AM
Hi Krishna,

You can achieve this by just setting the row style to bold in row bound data event as below.

protected void GridView1_DataBound(object sender, EventArgs e)
{
    GridView1.Rows[1].Style.Add(HtmlTextWriterStyle.FontWeight, "Bold");
}


Hope the above helps.

Thanks & Regards,
Rajasekhar.R
aneesa replied to Krishna T on 01-Oct-12 01:41 AM
<asp:BoundField DataField="ColumnName" HeaderText="Column1" ItemStyle-Font-Bold="true"/>
help
In a ASP.NET page I want to refresh only a gridview in time interval of 30 secs instead of autorefresh the whole page. How to do asp : Label ID = "Label2" runat = "server" Text = "This is Time, When The Full Page Load :" Font-Bold = "true"> < / asp : Label > &nbsp; < asp : Label ID = "MyLabel" runat = "server"> < / asp : Label > < br / > < br / > < asp ID = "Label3" runat = "server" Text = "This is The Time when Only Data Grid will Referesh :" Font-Bold = "true"> < / asp : Label > &nbsp; < asp : Label ID = "Label1" runat = "server" Text = "Grid not refreshed yet br / > < asp : Label ID = "Label4" runat = "server" Text = "(Grid Will Referesh after Every 30 Sec)" Font-Bold = "true"> < / asp : Label > &nbsp; < br / > < br / > < asp : DataGrid ID = GridData runat = "server" Width = "100%" GridLines
Hi all, I want to delete selected rows from gridview for this I have written the below code but getting exception: An unhandled exception of type 'System.StackOverflowException' occurred in System.Web.dll Here is my aspx.page: <asp:gridview ID = "Gridview1" runat = "server" ShowFooter = "true" onrowcommand = "Gridview1_RowCommand" AutoGenerateColumns = "false" CellSpacing = "0" CellPadding = "0" Font-Bold = "false" onrowdeleting = "Gridview1_RowDeleting"> <Columns> <asp:TemplateField HeaderText = "Select" ControlStyle-Width = "50px" HeaderStyle-Font-Bold = "false" ControlStyle Font-Bold = "false"> <ItemTemplate> <asp:CheckBox ID = "chkSelect" runat = "server" Width = "80px" / > < / ItemTemplate> < / asp:TemplateField> <asp
Hi All, How is it possible to bold one row of the gridview and unbold another row. I have the ID's of both rows stored in a is it possible? I really need help with this. So is this an ASP.NET gridview? You posted in the JavaScript topic. You can defiinitely do what you ask but first answers. HI You can loop through your rows by using. DataGridViewCellStyle style = new DataGridViewCellStyle (); style . Font = new Font ( dataGridView . Font , FontStyle . Bold ); foreach ( DataGridViewRow dg_r in myDataGridView . rows ) { dg_r . DefaultCellStyle = style ; / / sets Row Style to
Hi, I have a datagridview in my form. All i have to do is to change the font style of first column to bold. The datagridview is attached to a datatable. I am using the following code but it is not working. this .datagridview1.Columns[0].DefaultCellStyle.Font = new Font ( this .Font, FontStyle .Bold); please help!! Try something like this; You need to use CellFormatting event to achive this
48 PM Hi all, I am struglling a lot to find out the total of gridview cells and displaying the values Footer textbox. Every time I am getting the exception: Pls am doing: This is the exception: Microsoft JScript runtime error: Object expected Here is my gridview code: <div> <asp:gridview ID = "Gridview1" runat = "server" ShowFooter = "true" onrowcommand = "Gridview1_RowCommand" AutoGenerateColumns = "false" CellSpacing = "0" CellPadding = "0" Font-Bold = "false" onrowdeleting = "Gridview1_RowDeleting"> <Columns> <asp:BoundField DataField = "RowNumber" HeaderText = "Row Number" / > <asp:TemplateField HeaderText = "Select ControlStyle-Width = "50px" HeaderStyle-Font-Bold = "false" ControlStyle-Font-Bold = "false"> <ItemTemplate> <asp:CheckBox ID = "chkSelect" runat = "server" Width = "80px" / > < / ItemTemplate> < / asp:TemplateField> <asp
07:30 PM Post ur que description by replying ur own que TRY THIS <asp:GridView ID = "CustomerGrid" runat = "server" BackColor = "White" AutoGenerateColumns = "False" BorderColor = "#336666" BorderStyle = "Double" BorderWidth = "3px" CellPadding ForeColor = "#333333" / > <%- - < HeaderStyle CssClass = "HeaderFreeze" / > - - %> <Columns> <asp:BoundField DataField = "Ref_No" HeaderText = "Deal / Transfer Ref # " > <HeaderStyle Font-Names = "Verdana" Font-Size = "11px" / > <ItemStyle Font-Names = "Verdana" Font-Size = "11px" Width = "180px" ForeColor = "Blue" Font-Bold = "true" / > < / asp:BoundField> <asp:BoundField DataField = "Settlement_Date" HeaderText = "Settlement Date" > <HeaderStyle Font-Names = "Verdana" Font-Size = "11px" / > <ItemStyle Font-Names = "Verdana" Font-Size = "11px" / > < / asp:BoundField> <asp
this is my gridview design code < asp : GridView ID = "GridView1" runat = "server" style = "left: 205px; position: relative; top: 43px" CellPadding = "4" ForeColor = "#333333 GridLines = "None" Height = "282px" Width = "454px" AutoGenerateColumns = "False" AllowPaging = "True"> < FooterStyle BackColor = "#507CD1" Font-Bold = "True" ForeColor = "White" / > < RowStyle BackColor = "#EFF3FB" / > < EditRowStyle BackColor = "#2461BF" / > < SelectedRowStyle BackColor = "#D1DDF1" Font-Bold = "True" ForeColor = "#333333" / > < PagerStyle BackColor = "#2461BF" ForeColor = "White" HorizontalAlign = "Center" / > < HeaderStyle BackColor = "#507CD1" Font-Bold = "True" ForeColor = "White" / > < AlternatingRowStyle BackColor = "White" / > < Columns > < asp : BoundField DataField = "schl_code" HeaderText = "School Code
error;; pls help ASP.NET 28-Oct-12 07:50 PM Compilation Error body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt
sir, ive data grid, in this grid i bind some fields, i want to display some row font bold and some row font regular, as like in yahoo mail's inbox(read message font regular, and unread message font bold) using System.Data; using System.Data.OleDb; string strSQL = "Select * From Customers"; OleDbConnection Connection = new datagrid. try this <asp:DataGrid runat = "server" ID = "dgEmp" Width = "100%"> <Columns> <asp:TemplateColumn ItemStyle-Font-Bold = "true"> <ItemTemplate> Name < / ItemTemplate> < / asp:TemplateColumn> <asp:TemplateColumn ItemStyle-Font-Bold = "false" ItemStyle-BackColor