我正在尝试在我的网络服务中调用一个函数。相同的技术用于页面上的不同区域,但这个似乎不起作用。
这是 aspx 语法:
<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>
btnDeleteTicket_Command
功能:
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();
}
}
网络服务的联系方式如下:
webService.Festivals_DeleteTicketFestival("1", "3");
Festivals_DeleteTicketFestival(String festId, String typId)
功能:调试时,我可以看到webservice中的festId和typId为null 。
[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;
}
也许有更多经验的人可以发现问题?谢谢!