-1
I have a NO DATABASE ENTERED page, the registration data is being stored in Session. I am using a Reset to store this. The delete command that I used before was through Reset, which is wrong because it has to be done by Session otherwise the operation is not correct. How can I do that? I’ve tried Session.Abandon; Session.Remove; Session.Removeat I’m starting to use c# Asp.net now
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<HeaderTemplate>
<tr>
<td>Ações:</td>
<td>Nome:</td>
<td> ....</td>
</tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td>
<asp:button ID="btnAlterar" runat="server" CommandName="Alterar" OnCommand="btnAlterar_Click" text="Alterar"></asp:button>
<asp:button ID="btnExcluir" runat="server" CommandName="Excluir" OnCommand="btnExcluir_Click" text="Excluir"></asp:button>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Nome") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Email") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Nasci") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Cpf") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Cidade") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Estado") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Endereco") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Num") %>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>//Table onde está o Repeater e os Botões
Repeater itemCommand:
protected void Repeater1_itemcommand(Object source, Repeatercommandeventargs and) {
switch (e.CommandName)
{
case "Alterar":
break;
case "Excluir":
Session.Contents.Remove("lst");
break;
}
}
This is how data is being stored in Session:
Person p = new Person();
p.Nome = txtNome.Text;
p.Email = txtEmail.Text;
p.Nasci = txtNasci.Text;
p.Cpf = txtCpf.Text;
p.Cidade = txtCidade.Text;
p.Estado = ListEstado.Text;
p.Endereco = txtEndereco.Text;
p.Num = Repeater1.Items.Count;
if (Session["lst"] == null)
{
List<Pessoa> lstNova = new List<Pessoa>();
lstNova.Add(p);
Session["lst"] = lstNova;
Repeater1.DataSource = lstNova;
Repeater1.DataBind();
}
else
{
List<Pessoa> lstTodoMundo = (List<Pessoa>)Session["lst"];
lstTodoMundo.Add(p);
Repeater1.DataSource = lstTodoMundo;
Repeater1.DataBind();
}
I only managed to perform the tests today...but thank you so much is working properly! Thank you so much :))
– Gustavo Luiz
Not at all @Gustavoluiz. See you around ;)
– Raquel Pinheiro