Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > chkBox datagrid question

Thread Tools

chkBox datagrid question

Posts: n/a
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

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
' DeleteItem(grdUinv.DataKeys(e.Item.ItemIndex).ToSt ring)

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!


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chkbox in datagrid =?Utf-8?B?UmJhbkJwaA==?= ASP .Net 2 01-05-2006 02:36 PM
Javascript : pass chkbox value as parameter in to MSRS report jaya Javascript 1 11-10-2005 12:58 PM
datagrid in datagrid BK Kim ASP .Net 1 03-02-2004 06:34 AM
Call Datagrid Command column outside datagrid Dave ASP .Net 0 11-20-2003 11:11 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM