Hein,
Thanx for the replies, but I seemed to forget to mention one thing. My
application uses C# webforms, so I can't use
System.Windows.Forms.BindingContext.
I can think of two possible ways.
First, a DataGrid:
<ASP
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
ATAGRID id="myDataGrid" runat="server"
onitemcommand="myDataGrid_ItemCommand">
<COLUMNS>
<ASP:BUTTONCOLUMN HeaderText="Select Row"
ButtontType="PushButton"
Text="Select"
CommandName="SelectRow">
</ASP:BUTTONCOLUMN>
<ASP:BOUNDCOLUMN HeaderText="MyID" datafield="MyID">
</ASP:BOUNDCOLUMN>
</COLUMNS>
</ASP
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
ATAGRID>
Then in your code behind file either:
1. Store the DataSet for the Grid in Session State (depending on its size)
and:
protected void myDataGrid_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
TableCell myID = e.Item.Cells[1];
string key = myID.Text;
DataRow[] dr =
((DataSet)Session["MyDataSet"]).Tables[0].Select("MyID=" + key);
}
or
(2) go back to the database with the id and get the single record:
protected void myDataGrid_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
TableCell myID = e.Item.Cells[1];
int id = int.Parse(myID.Text);
if(((Button)e.CommandSource).CommandName == "SelectRow")
{
DataRow dr = // fetch the record from the database using the id
}
}