SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 121 | Next

Joydip Kanjilal

"ASP.NET Data Presentation Controls Essentials"

NET
[ 126 ]
="Department">





Note how the styles have been applied using the style sheet given earlier in this
section. We have used the SalaryBar class of our style sheet to customize the
tag that relates to salary. Here is the source code that illustrates how you will bind
data to the DataGrid control.
protected double MAXSALARY;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
DataManager dataManager = new DataManager();
MAXSALARY = double.Parse(dataManager.GetMaxSalary());
dgEmployee.DataSource = dataManager.GetEmployees();
dgEmployee.DataBind();
}
}
The GetMaxSalary() has been introduced new to our DataManager class. The intent
of this method is returning the maximum salary of all the employees in the table.
Following is the source code for the method.
public String GetMaxSalary()
{
SqlConnection conn = null;
try
{
conn = new SqlConnection(connectionString);
conn.Open();
string sql = "Select Max(Salary) from Employee";
SqlCommand cmd = new SqlCommand(sql, conn);
return cmd.ExecuteScalar().ToString();
}
catch
{
throw;
}
finally
{
conn.Close();
}
}
Chapter 5
[ 127 ]
For formatting the date type values in a DataGrid control you can use
DataFormatString as shown below.


Pages:
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6