Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.net VB Gridview Update cast values
    primarykey
    data
    text
    <p>I have a GridView with datasource from the MS Access database. It is </p> <blockquote> <p>SELECT * FROM [TODO] ORDER BY [Name]</p> </blockquote> <p>The UPDATE query is</p> <blockquote> <p>UPDATE [TODO] SET [Staff] = CInt(@Staff), [Title] = @Title, [Deadline] = @Deadline, [Status] = CInt(@Status) WHERE [todoID] = @ID</p> </blockquote> <p>Two of the returned values are foreign keys (integer) for another tables - Status and Staff So I replaced two EditItemTemplates with DropDownLists, assigning them other DataSources and binding the selected index to the foreign key.</p> <p>This results in GridView generating this HTML:</p> <pre><code>&lt;select name="ctl00$ContentPlaceHolder1$GridView1$ctl02$DropDownList1" id="ContentPlaceHolder1_GridView1_DropDownList1_0"&gt; &lt;option value="1"&gt;John Doe&lt;/option&gt; &lt;option value="2"&gt;William Jenkins&lt;/option&gt; &lt;option value="3"&gt;Kate Piper&lt;/option&gt; &lt;option selected="selected" value="4"&gt;Alison Fisher&lt;/option&gt; &lt;/select&gt; </code></pre> <p>And this results in the following ASP.NET error when updating the record</p> <blockquote> <p>Exception Details: System.Data.OleDb.OleDbException: Invalid use of Null</p> </blockquote> <p>I also tried not to cast values in the query - still no success, but another error is thrown:</p> <blockquote> <p>Conversion from type 'DBNull' to type 'Integer' is not valid.</p> </blockquote> <p>I am really new in ASP.NET, all my experience is based on other languages. I will really appreciate any help</p>
    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.
    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