31
Answers

Datagridview weird behaviour

When I change a value in a cell the record is updated via a SQL Insert statement which works fine. When I don't change a value in a cell and just tab to the next cell, it removes all the current rows from the datagridview and renders a new row.

Answers (31)
1
Smit Thakur

Smit Thakur

NA 72 2 7y
Try this:
 
foreach (var item in storeItem)
{
<input type="button" id="btn" value="@item.StoreItemName" onclick="addvalue($(this))" />
}
<script>
function addvalue(e) {
$('#ItemName').val(e.val())
}
</script>
0
Midhun T P

Midhun T P

NA 19.7k 281.1k 7y
Hi,
 
Please try like below -
 
<input type="button" id="btn" value="@item.StoreItemName" onclick="addvalue(this.value)" /> 
 
script -
 
function addvalue(myval) {
$('#ItemName').val(myval);
}
 
 The error in your question is not from the script you provided. It was coming from some other script. 
0
Shakil Ahmed

Shakil Ahmed

NA 49 1.2k 7y
@if (TempData["srResult"] != null)
{
List<StoreItem> storeItem = (List<StoreItem>)TempData["srResult"];
foreach (var item in storeItem)
{
<input type="button" id="btn" value="@item.StoreItemName" onclick="addvalue()" />
}
}
0
Ankit Sharma

Ankit Sharma

NA 8.8k 140.9k 7y
Hi,
 
Please post you whole Jquery code as  error is with "toLowerCase" method and that code snippet is not present in this screenshot.
 
Please refer 
 
https://stackoverflow.com/questions/23723005/uncaught-typeerror-cannot-read-property-tolowercase-of-undefined 
 
https://teamtreehouse.com/community/uncaught-typeerror-cannot-read-property-tolowercase-of-undefined