i've written webmail like program. in this, unread mails should be bold in gridview. I did this but the problem is if unread means all the rows are bold. i need unread mails only bold. how to set the particular rows are bold programmatically in asp.net?
anyone help me asap.
after re-reading I think you were trying to make the read rows non-bold on the databind. My appologies. Here is an example of how I would go about this.
gtkumaran6
0 Points
2 Posts
how to set gridview particular row bold in asp.net
Jun 29, 2012 05:32 AM|LINK
hi
i've written webmail like program. in this, unread mails should be bold in gridview. I did this but the problem is if unread means all the rows are bold. i need unread mails only bold. how to set the particular rows are bold programmatically in asp.net? anyone help me asap.
thanks in advance
sumitacc
Member
185 Points
53 Posts
Re: how to set gridview particular row bold in asp.net
Jun 29, 2012 05:45 AM|LINK
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 =
<div>true;</div> <div> </div> <div> </div> <div> </div> <div>Please mark the replies as answers if they help.</div>Software Developer
India
gtkumaran6
0 Points
2 Posts
Re: how to set gridview particular row bold in asp.net
Jun 29, 2012 11:02 AM|LINK
hi
first of all thanks for ur reply.
it doesnt help brother. i need particular row bold means unread mails are bold else normal.i thk now u can understand.
can u send gridview's which event i write the code?
thanks once again
RameshRajend...
Star
7983 Points
2099 Posts
Re: how to set gridview particular row bold in asp.net
Jun 29, 2012 11:09 AM|LINK
this will make 1st row bold
GridView1.Rows(0).Font.Bold = True
Pls look more usefull liks
http://forums.asp.net/t/1389797.aspx/2/10
http://forums.asp.net/t/1503665.aspx/1
http://forums.asp.net/t/1758305.aspx/1
Thank u
mdank
Member
70 Points
12 Posts
Re: how to set gridview particular row bold in asp.net
Jun 29, 2012 02:21 PM|LINK
If you are using a ButtonField this is how I do it..
Here is the GridView
<asp:GridView ID="grid" runat="server" OnRowCommand="grid_OnRowCommand" RowStyle-Font-Bold="true" AutoGenerateColumns="false">
<Columns>
<asp:ButtonField CommandName="select" Text="select" />
<asp:BoundField DataField="dataField1" />
</Columns>
</asp:GridView>
Here is my code behind
protected void grid_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "select")
{
grid.Rows[Convert.ToInt32(e.CommandArgument)].Font.Bold = false;
}
}
Hope this helps
mdank
Member
70 Points
12 Posts
Re: how to set gridview particular row bold in asp.net
Jun 29, 2012 02:58 PM|LINK
after re-reading I think you were trying to make the read rows non-bold on the databind. My appologies. Here is an example of how I would go about this.
Sample Grid:
<asp:GridView ID="grid" runat="server" OnDataBound="grid_DataBound" RowStyle-Font-Bold="true" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="dataField1" />
<asp:BoundField DataField="dataFieldRead" />
</Columns>
</asp:GridView>
Populating the gridview:
DataTable dtBind = new DataTable();
dtBind.Columns.Add("dataField1", typeof(string));
dtBind.Columns.Add("dataFieldRead", typeof(bool));
DataRow drow1 = dtBind.NewRow();
drow1[0] = "test1";
drow1[1] = false;
dtBind.Rows.Add(drow1);
DataRow drow2 = dtBind.NewRow();
drow2[0] = "test2";
drow2[1] = true;
dtBind.Rows.Add(drow2);
DataRow drow3 = dtBind.NewRow();
drow3[0] = "test3";
drow3[1] = false;
dtBind.Rows.Add(drow3);
this.grid.DataSource = dtBind;
this.grid.DataBind();
On the dataBound step through the rows
protected void grid_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow drow in grid.Rows)
{
if (Convert.ToBoolean(drow.Cells[1].Text))
{
drow.Font.Bold = false;
}
}
}
Not sure if this is the most efficient way of doing this.. feel free to comment.