Hello all,
I am using c# .net.
aspx form
<asp:Table ID="viewV" runat="server">
<asp:TableRow>
<asp:TableHeaderCell>Name</asp:TableHeaderCell>
<asp:TableHeaderCell>Type</asp:TableHeaderCell>
</asp:TableRow>
</asp:Table>
Code Behind
vRepository getV = new vRepository();
var viewAllV = getV.GetV();
foreach (tblV singleV in viewAllV)
{
TableRow tr = new TableRow();
// Create four new cells for each row within the database
TableCell vName = new TableCell();
TableCell vType = new TableCell();
// Attached values to each of these cells
vName.Text = singleV.vName;
vType.Text = singleV.tblVType.vName;
// Add the cells to the table
tr.Cells.Add(vName);
tr.Cells.Add(vType);
// Add the row to the table
viewV.Rows.Add(tr);
}
I am currently populating a asp:table using LINQ, this is working fine.
public IQueryable<tblV> GetV()
{
return (from getAllV in dc.tblV
where getAllV.deleted != 1
orderby getAllV.vName
select getAllV).DefaultIfEmpty();
}
I have tried the GridView/ListView/DetailsView but can’t seem to access the GetV, I can only access the actual table.
I want to add a edit/delete button to the end of every row, so that the user can select the row they wish to edit/delete.
Once the user has selected either the edit/delete button, this should then access a different view (one for edit, one for add - within the same aspx file).
For example:
Name Type
Example 1 Type 1 Edit Button Delete Button
Example 2 Type 1 Edit Button Delete Button
I want to be able to select the Edit Button for ‘Example 1’. This should then:
- Take me to the ‘edit view’
- Auto populate the two text fields with the correct information.
- Update row (within database) with new information using unique ID(PK)
How came I produce multiple edit/delete buttons which somehow hold the unique ID for that row?
I thought it would be something like this:
TableCell vEdit = new TableCell();
vEdit.Button = singleV.vID;
tr.Cells.Add(vEdit);
Thanks in advance for any help.
Clare