Cheers to my first 6hours of coding ... but that's the catch when you start (or start over) ... you get stuck with silly problems:
I have created a DataGrid with a DataSet from a search result class-
Now I've added a button in my rows to get a new form with the details of that element:
private void dgSearchResult_ItemCommand(object sender, DataGridCommandEventArgs e)
{
switch (e.CommandName)
{
case "ViewItem":
ViewItem(e);
break;
default:
break;
}
}
private void ViewItem(DataGridCommandEventArgs e)
{
// to get the new form with the details of the row e
}
Now 2 things :
- 1st the silliest : What is the command to post a new form? It's kinda silly that I get that far but I can't change the form...
-2nd : I've been looking around to create that eventHandler ItemCommand and I stumbled accross this variation
switch (((LinkButton)e.CommandSource).CommandName)
//or I thought in my case
switch (((PushButton)e.CommandSource).CommandName)
and I couldn't find anything for that LinkButton Cast...
I finally just removed the whole thing and tried with just e.CommandName
and it worked.
Is that ok (seems to work fine but I wonder if it is the proper way) or will I get unexpected behaviours?
Thank you for your help and patience