G
Google Jenny
Hello,
I've created a DataGrid (C#) and populated it with data. Here's the
code:
private void PopulateButton_Click(object sender, System.EventArgs e)
{
OleDbConnection MyConnection = new OleDbConnection
(Connection String is here);
OleDbCommand MyCommand = new OleDbCommand();
MyCommand.CommandText = "Select GRADUATES, ROSTERID,"+
"rtrim(LASTNAME) +', ' + rtrim(FIRSTNAME) as NAME from sf1 order by
NAME";
MyCommand.Connection = MyConnection;
try
{
MyConnection.Open();
DataGrid1.DataSource = MyCommand.ExecuteReader();
DataGrid1.DataBind();
MyConnection.Close();
}
catch(Exception ex)
{
//An error occured
HttpContext.Current.Response.Write(ex.ToString());
}
}
What I'd like to do now is make the NAME column clickable so that I can
make things happen when the user clicks on a name in the NAME column. I
don't know how to make anything in a Data Grid clickable.
While I've been able to do this with List Boxes, (Using
SelectedIndexChanged), I have no idea how to do this with Data Grids. I
have a feeling it's a very different paradigm.
Any help most appreciated.
Thanks,
Google Jenny
I've created a DataGrid (C#) and populated it with data. Here's the
code:
private void PopulateButton_Click(object sender, System.EventArgs e)
{
OleDbConnection MyConnection = new OleDbConnection
(Connection String is here);
OleDbCommand MyCommand = new OleDbCommand();
MyCommand.CommandText = "Select GRADUATES, ROSTERID,"+
"rtrim(LASTNAME) +', ' + rtrim(FIRSTNAME) as NAME from sf1 order by
NAME";
MyCommand.Connection = MyConnection;
try
{
MyConnection.Open();
DataGrid1.DataSource = MyCommand.ExecuteReader();
DataGrid1.DataBind();
MyConnection.Close();
}
catch(Exception ex)
{
//An error occured
HttpContext.Current.Response.Write(ex.ToString());
}
}
What I'd like to do now is make the NAME column clickable so that I can
make things happen when the user clicks on a name in the NAME column. I
don't know how to make anything in a Data Grid clickable.
While I've been able to do this with List Boxes, (Using
SelectedIndexChanged), I have no idea how to do this with Data Grids. I
have a feeling it's a very different paradigm.
Any help most appreciated.
Thanks,
Google Jenny