I'm trying to call a function in my webservice. The same technique is used for different areas on the page, but this one doesn't seem to work.
This is the aspx syntax:
<asp:Repeater ID="rptDeleteTickets" runat="server">
<ItemTemplate>
<asp:UpdatePanel ID="DeleteTicketUpdatePanel" runat="server">
<ContentTemplate>
<li>
<asp:Label ID="lblTicketDescD" runat="server" Text='<%# Eval("typ_omschr") %>' /></li>
<li style="border-bottom: 1px solid white;">
<asp:Label ID="lblTicketPriceD" runat="server" Text='<%# Eval("typ_prijs") %>' />
<asp:ImageButton ID="btnDeleteTicket" runat="server" ImageUrl="~/Images/minus.png" Width="20px"
OnCommand="btnDeleteTicket_Command" CommandName='<%# Eval("typ_id") %>' meta:resourcekey="btnDeleteTicketResource1" />
</li>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:Repeater>
The btnDeleteTicket_Command
function:
protected void btnDeleteTicket_Command(object sender, CommandEventArgs e)
{
try
{
String strTypId = e.CommandName.ToString();
int intResult = webService.Festivals_DeleteTicketFestival("1", "3");
divResult.Visible = true;
lblResult.ForeColor = System.Drawing.Color.White;
if (intResult == 1)
{
lblResult.Text = GetLocalResourceObject("SaveSuccess").ToString();
dsTicketsPerFestival = webService.Festivals_GetTicketTypesOfFestival(strFormIdFest);
Session["TicketsPerFestival"] = dsTicketsPerFestival;
}
else if (intResult == -1)
{
lblResult.ForeColor = System.Drawing.Color.LightSalmon;
lblResult.Text = GetLocalResourceObject("ErrorNoDeleted").ToString();
}
else if (intResult > 1)
{
lblResult.Text = GetLocalResourceObject("ErrorMultipleDeleted").ToString();
dsTicketsPerFestival = webService.Festivals_GetTicketTypesOfFestival(strFormIdFest);
Session["TicketsPerFestival"] = dsTicketsPerFestival;
}
}
catch (Exception fatal)
{
divResult.Visible = true;
lblResult.ForeColor = System.Drawing.Color.LightSalmon;
lblResult.Text = GetLocalResourceObject("Error").ToString();
}
}
The webservice is contacted like this:
webService.Festivals_DeleteTicketFestival("1", "3");
The Festivals_DeleteTicketFestival(String festId, String typId)
function:
When debugging, i can see that festId and typId are null inside the webservice.
[WebMethod]
public int Festivals_DeleteTicketFestival(String festId, String typId)
{
return Festivals_DeleteTicketFestival(festId, typId); //StackOverflowException shown here
}
public int deleteTicketFestival(String festId, String typId)
{
int deletedRows = -1;
try
{
sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["project"].ConnectionString);
sqlCommand = new SqlCommand("DeleteTicketFestival", sqlConnection);
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlAdapter = new SqlDataAdapter(sqlCommand);
sqlCommand.Parameters.Add(new SqlParameter("@festId", festId));
sqlCommand.Parameters.Add(new SqlParameter("@typId", typId));
sqlConnection.Open();
sqlTransaction = sqlConnection.BeginTransaction();
sqlCommand.Transaction = sqlTransaction;
deletedRows = sqlCommand.ExecuteNonQuery();
sqlTransaction.Commit();
}
catch (Exception e)
{
LoggingService.WriteLine(strApplicationName + " Delete festival ticket", e.Message);
if (sqlTransaction != null)
{
sqlTransaction.Rollback();
throw (e);
}
}
return deletedRows;
}
Maybe someone with more experience can spot the issue? Thanks!
public int Festivals_DeleteTicketFestival(String festId, String typId)
{
return Festivals_DeleteTicketFestival(festId, typId); //StackOverflowException shown here
}
you are recursively calling the same function without having an ending criteria (in fact you do not do anything except making this recursive call in your function). This will cause the StackOverflowException.
If you change it to
return deleteTicketFestival(festID, TypID)
your problems involving this error should be solved.