G
Guest
Hello all,
I have a datagrid with a checkbox as a template. I connected my two
chekboxes in the template to my my datasource in the propeties menu. But I
get this error flagged at line 33.
"Index 0 is not non-negative and below total rows count. "
<asp:TemplateColumn HeaderText="Sold">
Line 32: <ItemTemplate>
<<<Line 33: <asp:CheckBox id=chkITsold runat="server"
AutoPostBack="True" Checked='<%# DataBinder.Eval(DsUinv1,
"Tables[IMSProducts].DefaultView.>>>[0].Sold") %>'>
Line 34: </asp:CheckBox>
Line 35: </ItemTemplate>
When I disconnect the checkboxes from the db, it' fine.
I also ahave a quick question on my code for the checkboxe in my item
command. Having problems with a "Object not refrenced error" on my chkbox
line. Not sure if this has something to do with not being connected to the
database, or I coded the line wrong.
Private Sub grdUinv_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
grdUinv.ItemCommand
If e.Item.ItemType = ListItemType.Pager Or _
e.Item.ItemType = ListItemType.Header Then Exit Sub
''' grdUinv.EditItemIndex = -1
Dim btn As Button = CType(e.CommandSource, Button)
If btn.Text = "Edit" Then
txbProductID.Text = e.Item.Cells(0).Text
txtProdName.Text = e.Item.Cells(1).Text
txtModNum.Text = e.Item.Cells(2).Text
txtSrp.Text = Microsoft.VisualBasic.Right(e.Item.Cells(3).Text, _
Len(e.Item.Cells(4).Text) - 1)
txtCost.Text = Microsoft.VisualBasic.Right(e.Item.Cells(4).Text, _
Len(e.Item.Cells(5).Text) - 1)
txtQty.Text = e.Item.Cells(5).Text
' chkEbay.Checked =
CType(e.Item.Cells(6).FindControl("chkEbay"), _
' CheckBox).Checked
chkSold.Checked =
CType(e.Item.Cells(6).FindControl("chkITSold"), CheckBox).Checked
pnlAdd.Visible = True
Else
' DeleteItem(grdUinv.DataKeys(e.Item.ItemIndex).ToString)
End If
btnSave.CommandArgument = ""
End Sub
I do have a panel below that I can ADD items to the database, including the
checkbox, that works just fine. My other columns work fine too, just the
chkbox on the datagrid is giving me flak!
TIA!!!!
Rudy
I have a datagrid with a checkbox as a template. I connected my two
chekboxes in the template to my my datasource in the propeties menu. But I
get this error flagged at line 33.
"Index 0 is not non-negative and below total rows count. "
<asp:TemplateColumn HeaderText="Sold">
Line 32: <ItemTemplate>
<<<Line 33: <asp:CheckBox id=chkITsold runat="server"
AutoPostBack="True" Checked='<%# DataBinder.Eval(DsUinv1,
"Tables[IMSProducts].DefaultView.>>>[0].Sold") %>'>
Line 34: </asp:CheckBox>
Line 35: </ItemTemplate>
When I disconnect the checkboxes from the db, it' fine.
I also ahave a quick question on my code for the checkboxe in my item
command. Having problems with a "Object not refrenced error" on my chkbox
line. Not sure if this has something to do with not being connected to the
database, or I coded the line wrong.
Private Sub grdUinv_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
grdUinv.ItemCommand
If e.Item.ItemType = ListItemType.Pager Or _
e.Item.ItemType = ListItemType.Header Then Exit Sub
''' grdUinv.EditItemIndex = -1
Dim btn As Button = CType(e.CommandSource, Button)
If btn.Text = "Edit" Then
txbProductID.Text = e.Item.Cells(0).Text
txtProdName.Text = e.Item.Cells(1).Text
txtModNum.Text = e.Item.Cells(2).Text
txtSrp.Text = Microsoft.VisualBasic.Right(e.Item.Cells(3).Text, _
Len(e.Item.Cells(4).Text) - 1)
txtCost.Text = Microsoft.VisualBasic.Right(e.Item.Cells(4).Text, _
Len(e.Item.Cells(5).Text) - 1)
txtQty.Text = e.Item.Cells(5).Text
' chkEbay.Checked =
CType(e.Item.Cells(6).FindControl("chkEbay"), _
' CheckBox).Checked
chkSold.Checked =
CType(e.Item.Cells(6).FindControl("chkITSold"), CheckBox).Checked
pnlAdd.Visible = True
Else
' DeleteItem(grdUinv.DataKeys(e.Item.ItemIndex).ToString)
End If
btnSave.CommandArgument = ""
End Sub
I do have a panel below that I can ADD items to the database, including the
checkbox, that works just fine. My other columns work fine too, just the
chkbox on the datagrid is giving me flak!
TIA!!!!
Rudy