As I stated in the original question, I was looking for a more elegant solution to the problem then what I eventually came up with. I didn't want to write any more code and I didn't want to hit the database again. I was looking for a way to fill the data reader and extract the group email from it while still filling the data grid. As it turns out, that's really not the most elegant way to do it. The Response.Redirect as every one has stated will always redirect to an empty page. My second post on this subject is the one with the solution that I came up with. I think that it's the best and it works. Here is the code that I used. As you will see, I eliminated the button all together.
private void LoadGroupEmail(string s)
{
// check s for the team name then laod all the data
OleDbConnection myConn = new OleDbConnection(Session["ConnStr"].ToString());
myConn.Open();
// add the query
string sql = "Select * from TeamRoster where Team = '" + s + "' and Name = 'Group Email'";
// create the command object
OleDbCommand myCommand = new OleDbCommand(sql,myConn);
// create an object to handle the return
OleDbDataReader Result = myCommand.ExecuteReader();
if (Result.HasRows)
{
if (Result.Read())
{
Session["GroupEmail"] = Result["Email"].ToString();
}
}
myConn.Close();
hlGroupEmail.Text = s + " Group Email";
hlGroupEmail.NavigateUrl = "mailto:" + Session["GroupEmail"];
}
private void LoadData(string s)
{
// check s for the team name then laod all the data
OleDbConnection myConn = new OleDbConnection(Session["ConnStr"].ToString());
myConn.Open();
// add the query
string sql = "Select * from TeamRoster where Team = '" + s + "' and Name <> 'Group Email'";
// create the command object
OleDbCommand myCommand = new OleDbCommand(sql,myConn);
// create an object to handle the return
OleDbDataReader Result = myCommand.ExecuteReader();
DataGrid1.DataSource = Result;
DataGrid1.Width = 600;
DataGrid1.DataBind();
myConn.Close();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
this.LinkButton3.Click += new System.EventHandler(this.LinkButton3_Click);
this.LinkButton4.Click += new System.EventHandler(this.LinkButton4_Click);
this.btnWings.Click += new System.EventHandler(this.btnWings_Click);
this.btnAlt.Click += new System.EventHandler(this.btnAlt_Click);
this.btnRefs.Click += new System.EventHandler(this.btnRefs_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LinkButton2_Click(object sender, System.EventArgs e)
{
// laod data for BOA
DataGrid1.BorderColor = System.Drawing.Color.RoyalBlue;
LoadData("Black Bears");
LoadGroupEmail("Black Bears");
}
You can view this in action by going to
http://www.ebhl.org
and clicking on the Rosters button at the top.
Thanks again
Jim