1
I have an Aspx page the following code which loads a list of items. It is working, the list is displayed normally.
<table width="100%" class="table table-striped">
<tr>
<th>Id</th>
<th>Nome</th>
<th>CPF</th>
<th>E-mail</th>
<th>Adicionar Telefone</th>
<th>Editar | Deletar</th>
</tr>
<% foreach (var item in pessoaList) { %>
<tr>
<td><%= item.id %></td>
<td><%= item.nome %></td>
<td><%= item.cpf %></td>
<td><%= item.email %></td>
<td><!-- Código Modal --></td>
<td>
<asp:Button ID="EditarPessoaButton" cssClass="btn btn-info" runat="server" CommandName="EditarPessoa" Text="Editar" ValidationGroup="EditarPessoa" onclick="EditarPessoaButton_Click"/>
<asp:Button ID="ExcluirPessoaButton" cssClass="btn btn-danger" runat="server" CommandName="ExcluirPessoa" Text="Excluir" ValidationGroup="ExcluirPessoa" onclick="ExcluirPessoaButton_Click"/>
</td>
</tr>
<% } %>
</table>
I intend to pass the value of <%= item.id %>
per row to table row as parameter to delete and edit data. I tried to use the Asp Textbox component to store the values but without success. I need the value <%= item.id %>
in aspx.cs. How to pass the value line by line of the <%= item.id %>
for the aspx.Cs layer?
[Edit] Note: I would like to pass all the values of the items between the Taglibs to text format to manipulate=los. Asp Textbox component says it is not supported when added between tags <td></td>
and also generates runtime error.
[Edit2] Follows resolution with Gridview
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%" OnRowCommand="GV_RowCommand" AllowSorting="True" DataSourceID="SqlDataSource1" AllowPaging="True" DataKeyNames="id" class="table table-striped" style="border-color:transparent; color:black;">
<Columns>
<asp:BoundField ReadOnly="True" HeaderText="ID" DataField="id" SortExpression="id" Visible="false"></asp:BoundField>
<asp:TemplateField Visible="False">
<ItemTemplate>
<asp:TextBox Text=<%# Eval("id")%> ID="txtIdPessoa" runat="server" visible="false"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="NOME" DataField="nome"
SortExpression="nome"></asp:BoundField>
<asp:BoundField HeaderText="CPF" DataField="cpf"
SortExpression="cpf"></asp:BoundField>
<asp:BoundField HeaderText="E-MAIL" DataField="email"
SortExpression="email"></asp:BoundField>
<asp:TemplateField HeaderText="TELEFONE">
<ItemTemplate>
<!-- Codigo Modal -->
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EDITAR | EXCLUIR">
<ItemTemplate>
<asp:Button Text="Editar" cssClass="btn btn-info" ID="btnUpdPessoa" runat="server" CausesValidation="false" CommandName="EditarPessoaButton_Click" CommandArgument='<%# Eval("id")%>' />
<asp:Button Text="Excluir" cssClass="btn btn-danger" ID="btnDelPessoa" runat="server" CausesValidation="false" CommandName="ExcluirPessoaButton_Click" CommandArgument='<%# Eval("id")%>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ItauDAL %>"
SelectCommand="select * from Pessoa"
UpdateCommand="UPDATE [Pessoa] SET [nome] = @nome , [cpf] = @cpf , [email] = @email
WHERE [id] = @id" >
<UpdateParameters>
<asp:Parameter Type="String" Name="nome"></asp:Parameter>
<asp:Parameter Type="String" Name="cpf"></asp:Parameter>
<asp:Parameter Type="String" Name="email"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>