chkBox datagrid question

Discussion in 'ASP .Net' started by =?Utf-8?B?UnVkeQ==?=, Mar 30, 2005.

  1. 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
     
    =?Utf-8?B?UnVkeQ==?=, Mar 30, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    0
    Views:
    449
  2. BK Kim

    datagrid in datagrid

    BK Kim, Feb 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    545
    Alvin Bruney [MVP]
    Mar 2, 2004
  3. =?Utf-8?B?UmJhbkJwaA==?=

    Chkbox in datagrid

    =?Utf-8?B?UmJhbkJwaA==?=, Jan 5, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    422
  4. Andreas Klemt
    Replies:
    0
    Views:
    310
    Andreas Klemt
    Oct 8, 2003
  5. jaya
    Replies:
    1
    Views:
    192
    Teo Lachev [MVP]
    Nov 10, 2005
Loading...

Share This Page