Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate Delete/Edit buttons for muliple records from linq using hidden value?
    primarykey
    data
    text
    <p>Aspx form:</p> <pre><code>&lt;asp:Table ID="viewV" runat="server"&gt; &lt;asp:TableRow&gt; &lt;asp:TableHeaderCell&gt;Name&lt;/asp:TableHeaderCell&gt; &lt;asp:TableHeaderCell&gt;Type&lt;/asp:TableHeaderCell&gt; &lt;/asp:TableRow&gt; &lt;/asp:Table&gt; </code></pre> <p>Code below:</p> <pre><code>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); } </code></pre> <p>I am currently populating a asp:table using LINQ, this is working fine.</p> <pre><code>public IQueryable&lt;tblV&gt; GetV() { return (from getAllV in dc.tblV where getAllV.deleted != 1 orderby getAllV.vName select getAllV).DefaultIfEmpty(); } </code></pre> <p><strong>I have tried the GridView/ListView/DetailsView but can’t seem to access the GetV, I can only access the actual table.</strong> </p> <p>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.</p> <p>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).</p> <p>For example:</p> <pre class="lang-none prettyprint-override"><code>Name Type Example 1 Type 1 Edit Button Delete Button Example 2 Type 1 Edit Button Delete Button </code></pre> <p>I want to be able to select the Edit Button for ‘Example 1’. This should then:</p> <ol> <li>Take me to the ‘edit view’,</li> <li>Auto populate the two text fields with the correct information,</li> <li>Update row (within database) with new information using unique ID(PK).</li> </ol> <p>How came I produce multiple edit/delete buttons which somehow hold the unique ID for that row?</p> <p>I thought it would be something like this:</p> <pre class="lang-cs prettyprint-override"><code>TableCell vEdit = new TableCell(); vEdit.Button = singleV.vID; tr.Cells.Add(vEdit); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload