Hi there, I've got a problem with this command. I' have a button inside a repeater with this piece of html:
When I run a dubug the program run only the first Statement, switch (e.CommandName.ToString()) and then exit from the routine.
I'can't explain why that appen.
Any help is appreciated.
Thx
Repeater:
<asp:Repeater runat="server" ID="rptDocumenti" OnItemCommand="rptDocumenti_OnItemCommand">
<ItemTemplate>
<li>
<asp:Literal runat="server" ID="litDocumento" Text='<%# httpLinkToADocument("http://" + ConfigurationManager.AppSettings["piattaforma"].ToString() + "/" + Eval("percorsoDocumento").ToString().Trim(), string.Format("{0}", Eval("nomeDocumento").ToString().Trim()), "_blank", "", "") %>' />
<span class="float-right"><i class="far fa-clock"></i><%# Convert.ToDateTime(Eval("dataInserimento").ToString()).ToString(" dd/MM/yyyy alle HH:mm") %></span>
<asp:LinkButton CssClass="btn btn-sm btn-danger ml-3" runat="server" ID="btnElimina" ToolTip="Elimina" CommandName="elimina" CommandArgument='<%# Eval("sysId").ToString() %>' Text="<i class='fas fa-trash'></i>" Visible='<%# !Convert.ToBoolean(Eval("obbligatorio").ToString()) %>' />
<asp:ConfirmButtonExtender ID="cbebtnElimina" runat="server" TargetControlID="btnElimina" ConfirmText="Conferma cancellazione" />
<hr class="m-1" />
</li>
</ItemTemplate>
</asp:Repeater>
C#:
protected void rptDocumenti_OnItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName.ToString())
{
case "elimina":
{
if (deleteAFile(getNomeDocumentoByIdDocumento(e.CommandArgument.ToString()), "~/Repository/Docs/"))
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
SqlCommand cmd = new SqlCommand("TDocumento_Delete", conn);
//add the parameter to the SqlCommand object
cmd.Parameters.Add("@sysId", SqlDbType.VarChar).Value = e.CommandArgument.ToString();
//open connection
conn.Open();
//set the SQLCommand type to StoredProcedure
cmd.CommandType = CommandType.StoredProcedure;
//execute the stored procedure
cmd.ExecuteNonQuery();
//close connection
conn.Close();
loadDocumenti(Request.QueryString["p"].ToString());
}
break;
}
default:
break;
}
}
When I run a dubug the program run only the first Statement, switch (e.CommandName.ToString()) and then exit from the routine.
I'can't explain why that appen.
Any help is appreciated.
Thx