Updating SQL from Gridview Checkbox Object reference not set to an instance of an object

Hello,
I know this is a common question.  I have a gridview and 2 cells have a checkbox.  I'm updating the data to a SQL table.  It comes up with error:
Object reference not set to an instance of an object.

I was updating this to Access and now the table is being moved to SQL and it's erroring out.

Using asp.net vb
aspx page:
<asp:GridView ID="gvEmployees" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="EmpID" DataSourceID=""  AllowPaging="False">
<Columns>

<asp:TemplateField HeaderText="Transfer" SortExpression="Transfers">
<EditItemTemplate><div align="center">
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# IIf(Eval("Transfers") Is DBNull.Value, "False", Eval("Transfers")) %>' /></div>
</EditItemTemplate>
<ItemTemplate>
<div align="center">
<asp:CheckBox ID="Transfers" runat="server" Checked='<%# IIf(Eval("Transfers") Is DBNull.Value, "False", Eval("Transfers")) %>'
      Enabled="false" /></div>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Promo" SortExpression="Promotions">
<EditItemTemplate><div align="center">
<asp:CheckBox ID="chkPromotions" runat="server" Checked='<%# IIf(Eval("Promotions") Is DBNull.Value, "False", Eval("Promotions")) %>' /></div>
</EditItemTemplate>
<ItemTemplate><div align="center">
<asp:CheckBox ID="chkPromotions" runat="server" Checked='<%# IIf(Eval("Promotions") Is DBNull.Value, "False", Eval("Promotions")) %>'
      Enabled="false" /></div>
</ItemTemplate>
</asp:TemplateField>            

<asp:CommandField ShowEditButton="True" ButtonType="Button" />
 </Columns>
</asp:GridView>

aspx.vb page
Imports System.Data
Imports System.Data.SqlClient

Imports DataSetClassIntranetSQL  (This gets the connection string)


Protected Sub gvEmployees_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles gvEmployees.RowUpdating
gvEmployees.EditIndex = -1

Dim strChange, strFrom, strTo As String
Dim strEmpID, strSQL As String
Dim intEmpID, recordUpdated As Integer

strEmpID = (DirectCast(gvEmployees.Rows(e.RowIndex).FindControl("lblEmpID"), Label).Text)
intEmpID = CInt(strEmpID)

Dim ckTfr As Boolean
ckTfr = DirectCast(gvEmployees.Rows(e.RowIndex).FindControl("Transfers"), CheckBox).Checked

Dim ckPromo As Boolean
ckPromo = DirectCast(gvEmployees.Rows(e.RowIndex).FindControl("chkPromotions"), CheckBox).Checked

strSQL = "SELECT empID, Promotions, Transfers FROM Employees WHERE empID = " & intEmpID & " "

Try
ds = GetDataSet(strSQL)

Catch ex As Exception
lbl1.Text = "Unable to retrieve ds: " & ex.ToString

End Try

With ds.Tables(0).Rows(0)
.Item("Promotions") = ckPromo
.Item("Transfers") = ckTfr

End With

recordUpdated = EmployeePhone.UpdateData(ds, strSQL)
ds.Dispose()
gvEmployees.EditIndex = -1

BindData()
End Sub

Any ideas?
LVL 2
jshesekAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

virtuadeptCommented:
Where are you declaring ds as a DataSet?
0
jshesekAuthor Commented:
Sorry - it's at the top of the class

Public ds As DataSet
    Public dt As DataTable
    Public dr As DataRow
    Public thisOrder As String
0
jshesekAuthor Commented:
Found the answer - it's in the first checkbox

<asp:TemplateField HeaderText="Transfer" SortExpression="Transfers">
<EditItemTemplate><div align="center">
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# IIf(Eval("Transfers") Is DBNull.Value, "False", Eval("Transfers")) %>' /></div>
</EditItemTemplate>
<ItemTemplate>
<div align="center">
<asp:CheckBox ID="Transfers" runat="server" Checked='<%# IIf(Eval("Transfers") Is DBNull.Value, "False", Eval("Transfers")) %>'
      Enabled="false" /></div>
</ItemTemplate>
</asp:TemplateField>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jshesekAuthor Commented:
The answer was in the front page - edit item and display item weren't the same name.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.