The return type for GridView1_RowCommand
is void, hence the method won't be able to return any data to the Show
method. There are 2 options which you can prefer to perform
- Call the
Show
method from theGridView1_RowCommand
method (Best option as .net framework performs the event calling for the grid)
e.g.
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Valj")
{
var valj = new Guid((string)e.CommandArgument);
var visadagbok = (from x in DagbokFactoryBase.All
where (x.ID == valj)
select x).FirstOrDefault();
Show(visadagbok);
}
}
- If you want to write an event based programming for lose coupling, for this you will need to create an property which invokes a delegate when the property value is set. Assign value to the property from the "GridView1_RowCommand". This delegate would invoke the "Show" method.
like:
public delegate void ShowHandler(string id);
public string Id
{
set
{
ShowHandler _show = new ShowHandler(Show);
if (_show != null)
{
_show(value);
}
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
//set of existing code
Id = visadagbok
}
public void Show(string Id)
{
//set of code
}