I am now very confused about how to create a gridview with the following structure and criteria:
note: gridview will accept data from different tables
columns: 1. IDcol is a unique value, and it will be from tableA (as text) 2. Date when it will also be with tableA (as text) 3. link1 this will be a hyperlink to another page, and the parameter for url will be the value "IDcol" but the displayed text will be changed if this record exists in table B with the same "IDcol" that the dispatched one will be "view / edit" "if it does not exist, it will be" Add new "
Database structure:
TABLEA:
IDcol as (primary key), Date
TableB:
ID, IDcol as (foreign key from tableA). other fields
so I need to populate the gridview using a loop, because I have to check every row and use some conditions
sorry if my description method is not clear but i really got confused
My code to remove the part:
<asp:LinkButton ID="DeleteLink" runat="server" Text="Delete" CommandName="Delete"></asp:LinkButton> </ItemTemplate> <ItemStyle Width="100px" /> </asp:TemplateField> DeleteCommand="DELETE VisitsInfo WHERE ID=@VID "> <DeleteParameters> <asp:Parameter Name="VID" Type="Int64" /> </DeleteParameters>
in the code behind:
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int VID = int.Parse(GridView1.DataKeys[0].Value.ToString()); SqlDataSourceVisits.DeleteParameters[0].DefaultValue = VID.ToString(); }
when I click the delete link to delete the line that works, but when the page is refreshed, the other line is deleted without the delete link, so why did this happen?
source share