private void PopulateGrid()
{
// Connect to the Database
SqlConnection objConnection = GetConnection();
objConnection.Open();
DataSet objDataSet = new DataSet("OD-Prod");
SqlDataAdapter objDataAdapter = new SqlDataAdapter();
// Construct the SqlStatement
string strCmd = "SELECT OD.ProductID,OD.Quantity,P.ProductName FROM [Order Details] OD, ";
strCmd += " Products P WHERE OD.ProductID=P.ProductID AND ";
if (OrderID.Text.Length > 0)
{
strCmd += "OD.OrderID = " + OrderID.Text;
}
else
{
objConnection.Close();
return;
}
SqlCommand selCommand = new SqlCommand(strCmd, objConnection);
objDataAdapter.SelectCommand = selCommand;
objDataAdapter.Fill(objDataSet, "JoinTable");
OrdGrid.DataSource = objDataSet.Tables["JoinTable"];
OrdGrid.DataBind();
}