moondaddy -
What I would recommend is that you use the events built into the grid control to handle the functions that you perform. I use the OnEditCommand OnDeleteCommand and the OnUpdateCommand in either a datalist or grid to handle the functions that you explain below. Below is an example of the OnDeleteCommand that would solve your checkbox problem below (this is from a datalist - but works with datagrid, too):
Sub listImages_Dele teCommand(ByVal s As Object, ByVal e As DataListCommand EventArgs)
Dim iImageID As String = listImages.Data Keys(e.Item.Ite mIndex)
Dim ImageName As String
Dim BaseImageFileLo c = ConfigurationSe ttings.AppSetti ngs("BaseFileLo c") & "images\"
Dim findDivisionNam e As New globalFunctions
Dim sDivisionName As String
With findDivisionNam e
.GalleryID = ddlGalleryID.Se lectedItem.Valu e
sDivisionName = .findDivisionNa me
End With
sSQL = "select imagename from images where imageid = " & iImageID
oConn.Open()
Dim cmd1 As New SqlCommand(sSQL , oConn)
Dim dr As SqlDataReader = cmd1.ExecuteRea der
Do While dr.Read
ImageName = dr.Item("imagen ame")
Loop
dr.Close()
oConn.Close()
'Response.Write (BaseImageFileL oc & sDivisionName & "\" & ImageName)
File.Delete(Bas eImageFileLoc & sDivisionName & "\" & ImageName)
Dim deleteImage As New imagesDB
With deleteImage
.oConn = oConn
.ImageID = iImageID
.deleteImage()
End With
listImages.Edit ItemIndex = -1
BindDataList()
End Sub
There are a lot of extra pieces of this Sub - but the important parts are the e.Items collection - that is the acutal row in the grid that you are working on. Let me know if this helps.
"moondaddy" wrote:
I have a datagrid where a user can edit a number in one of the columns for a
quantity value. On the postback I loop through all of the datagrid items
and if the quantity has changed, then I update the value of the extended
price cell for that datagrid item.
Also, the datagrid has a checkbox in each row called "Remove" where if the
checkbox is checked I delete that row from the underlying datasource and set
a flag which tells me to rebind the datagrid before the page sent back to
the client. Rather that raising a flag and rebinding the datagrid, I was
hoping I could simply remove that datagrid item (row) as I'm looping through
the items collection. Is this possible? (Something like 'item.delete'.. .)
Thanks.
--
mo*******@nospa m.com