Thursday, May 29, 2008

Dataset validation

if(ds != null && ds.Tables[0].Rows.Count > 0)
{
...
}

Tuesday, May 20, 2008

Get specific field count on a table

SELECT FieldName, COUNT(FieldName)
FROM Table
GROUP BY FieldName
order by COUNT(FieldName) desc

Monday, May 19, 2008

Change GridView backgrod color

aspx

< id="grdLicensedClients" runat="server" onrowdatabound="grdLicensedClients_RowDataBound">

c#

protected void grdLicensedClients_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drv = (DataRowView)e.Row.DataItem;

string areaCode = drv["Area"].ToString();

if (_duplicateAreaCodes.Contains(areaCode))
{
e.Row.BackColor = System.Drawing.Color.Yellow;
}
}
}