Hi Jonathan,
For DataGrid Row customization, a common approach is using the
"ItemDataBound" or "ItemCreated" event( GridView has "RowDataBound" and
"RowCreated" event). You can get the reference to database column
fields(pass through databinding) and change the certain property on Row (or
individual cells) in it. Here is a simple example that change the row's
Font-bold based on a column value:
======================
protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs
e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DataRowView drv = (DataRowView)e.Item.DataItem;
long id = (long)drv[0];
if (id > 3) e.Item.Font.Bold = true;
}
}
=======================
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Jonathan" <(E-Mail Removed)>
>Subject: Bold Text In Datgrid Row If strResult="Purchased"
>Date: Mon, 17 Mar 2008 04:48:22 +1200
>
>What code would I need to add below to make the text in datagrid rows bold
>when the value of one of the fields, "strResult" equals "Purchased"?
>
>Function bolPopulateDataGrid() as Boolean
>
> Dim oConn As OleDbConnection
> Dim oComm As OleDbDataAdapter
> Dim sConn As String
> Dim sComm As String
> Dim oDataSet As New DataSet
>
> 'Build the connection string
> sConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
> sConn += "Data Source=D:\inetpub\www\myweb\fpdb\db.mdb;"
> sConn += "Persist Security Info=False"
>
> 'Build the SQL string
> sComm = "SELECT qryDataGrid01.* "
> sComm += "FROM qryDataGrid01;"
>
>
> 'Create the connection and command objects
> oConn = New OleDbConnection(sConn)
> oComm = New OleDbDataAdapter(sComm, oConn)
>
> 'Fill the dataset with the results of the query
> oComm.Fill(oDataSet, sComm )
>
> 'Set the grid source to the dataset and bind the data
> oGrid.DataSource=oDataSet.Tables(sComm).DefaultView
> oGrid.DataBind()
>
>End Function
>
>
>
>