2
I’m a beginner and I’m trying to create a dynamic table that can be edited and deleted certain fields so I decided to use gridview. The problem I cannot solve is the position of this commandfield that I created to delete, it is always on the left and the rest of the table is fed dynamically by the database.
Useredit.aspx
<tbody id="tb" runat="server">
<asp:GridView ID="GridView1" runat="server" OnRowDeleting="GridView1_RowDeleting" CssClass="table table-bordered">
<Columns>
<asp:CommandField ItemStyle-HorizontalAlign="Right" ItemStyle-Width="20" HeaderStyle-HorizontalAlign="Right" DeleteText="<img src='imagens/recyclebin-512.png'" ShowDeleteButton="True" />
</Columns>
</asp:GridView>
</tbody>
Useredit.aspx.Cs
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = _sql.GetEditUtilizadores();
GridView1.DataSource = dt;
GridView1.DataBind();
}
To leave it on the right, I think you should use the Boundfields for each field.
– Augusto Henrique
Could you explain it a little better? What’s the difference?
– Afonso
Is in answer with code example ;)
– Augusto Henrique