Microsoft
Software
Hardware
Network
Question : I am trying to add an edit, delete function to an existing gridview
Here is the code. I have some declaration and coding error in the functions I am adding to the grid.
OnRowCancelingEdit="uxItem
DetailGrid
_RowCancel
ingEdit"
OnRowEditing="uxItemDetail
Grid_RowEd
iting"
OnRowUpdating="uxItemDetai
lGrid_RowU
pdating"
OnRowDeleting="uxItemDetai
lGrid_RowD
eleting"
I am getting this error
Compiler Error Message: BC30002: Type 'ContactTableAdapter' is not defined.
Source Error:
Line 131: Protected Sub uxItemDetailGrid_RowUpdati
ng(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
Line 132:
Line 133: Dim contact As New ContactTableAdapter()
Line 134:
Line 135: Dim txtName As TextBox = DirectCast(uxItemDetailGri
d.Rows(e.R
owIndex).F
indControl
("strNeeds
"), TextBox)
here is my aspx page and vb pages.
==========================
==========
==========
==========
===
<%@ Page Language="VB" Debug="false" AutoEventWireup="false" CodeFile="EventRegMeals.as
px.vb" Inherits="wwwroot_EventReg
Meals" %>
http://www.w3.org/TR/xhtm
l1/DTD/xht
ml1-transi
tional.dtd
">
nt size="4">CMAA Northern California Dinner Meeting Meal Selection
<
/td>
Print Instructions: Print in preview mode - Set to Landscape - Set Shrink Page to 85% - Click on Print preview.
Select Event Name:
Select Month:
em>
Janm>
Febm>
Marm>
Aprm>
Maym>
Junm>
Julm>
Augm>
Sepm>
Octem>
Novem>
Decem>
Select Year:
em>
2009tItem>
2010tItem>
2011tItem>
2012tItem>
2013tItem>
2014tItem>
2015tItem>
2016tItem>
2017tItem>
2018tItem>
2019tItem>
2020tItem>
2021tItem>
2022tItem>
2023tItem>
2024tItem>
2025tItem>
If you select a new event; reset the year.
OnRowCancelingEdit="uxItem
DetailGrid
_RowCancel
ingEdit"
OnRowEditing="uxItemDetail
Grid_RowEd
iting"
OnRowUpdating="uxItemDetai
lGrid_RowU
pdating"
OnRowDeleting="uxItemDetai
lGrid_RowD
eleting"
/>
"Center" HeaderText="Event
Date"
>
Text='<%# Eval("dtmEvent","{0:d}") %>'>
"Left" HeaderStyle-BackColor="#A1
C1D9" HeaderStyle-Font-Size="9" HeaderText="Event
Title
">
Text='<%# Eval("strTitle") %>'>
"Left" HeaderStyle-BackColor="#A1
C1D9" HeaderStyle-Font-Size="9" HeaderText="Company
Nam
e">
Text='<%# Eval("strName") %>'>
"Left" HeaderStyle-BackColor="#A1
C1D9" HeaderStyle-Font-Size="9" HeaderText="Meal
Select
ion">
'>
Text='<%# Eval("strNeeds") %>'>
"Center" HeaderStyle-BackColor="#A1
C1D9" HeaderStyle-Font-Size="9" HeaderText="Date
Regist
ered">
Text='<% #Eval("dtmCreated","{0:d}"
) %>'>
==========================
==========
==========
==========
==========
==========
=
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports System.IO
Imports System.Text
Imports System.Xml
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.
WebParts
Imports System.Web.UI.HtmlControls
Partial Public Class wwwroot_EventRegMeals
Inherits System.Web.UI.Page
Private iRowsCount As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim dtVolumeOrder As New DataTable()
Dim strSelectCommand As String = "SELECT e.dtmEvent,e.strTitle, r.strName, r.strNeeds,r.strEmail,r.fl
tOrderAmou
nt,r.blnEm
ailSent,r.
dtmCreated
FROM i2Integration_EventRegv45_
Event e,i2Integration_EventRegv4
5_Registra
tion r where e.intEventID = r.intEventID and r.blnEmailSent=1 Order by e.dtmEvent"
Using sqlConn As New SqlConnection(Configuratio
nManager.C
onnectionS
trings("Si
teSqlServe
r").Connec
tionString
)
Using adapPatientBills As New SqlDataAdapter(strSelectCo
mmand, sqlConn)
adapPatientBills.Fill(dtVo
lumeOrder)
End Using
End Using
uxItemDetailGrid.DataSourc
e = dtVolumeOrder
uxItemDetailGrid.DataBind(
)
Dim dtVolumeOrder2 As New DataTable()
Dim strSelectCommand2 As String = "SELECT distinct(strTitle),intEven
tID FROM i2Integration_EventRegv45_
Event order by intEventID"
Using sqlConn As New SqlConnection(Configuratio
nManager.C
onnectionS
trings("Si
teSqlServe
r").Connec
tionString
)
Using adapPatientBills As New SqlDataAdapter(strSelectCo
mmand2, sqlConn)
adapPatientBills.Fill(dtVo
lumeOrder2
)
End Using
End Using
DroplistData.DataSource = dtVolumeOrder2
DroplistData.DataTextField
= "strTitle"
DroplistData.DataBind()
End If
End Sub
Protected Sub DroplistData_SelectedIndex
Changed(By
Val sender As Object, ByVal e As System.EventArgs)
'Dim dtVolumeOrder As New DataTable()
'Where strTitle = '" + DroplistData.SelectedValue
+ "'"
'Dim strSelectCommand As String = "SELECT strTitle FROM i2Integration_EventRegv45_
Event"
'Using sqlConn As New SqlConnection(Configuratio
nManager.C
onnectionS
trings("Si
teSqlServe
r").Connec
tionString
)
'Using adapPatientBills As New SqlDataAdapter(strSelectCo
mmand, sqlConn)
'adapPatientBills.Fill(dtV
olumeOrder
)
'End Using
'End Using
'DroplistData.DataSource = dtVolumeOrder
'DroplistData.DataTextFiel
d = "strTitle"
'DroplistData.DataBind()
ddlYear.SelectedIndex = 0
End Sub
Protected Sub ddlMth_SelectedIndexChange
d(ByVal sender As Object, ByVal e As System.EventArgs)
'+ "' AND e.strTitle = '" + DroplistData.SelectedValue
Dim dtVolumeOrder As New DataTable()
Dim strSelectCommand As String = "SELECT e.dtmEvent,e.strTitle,r.st
rName, r.strNeeds, r.dtmCreated FROM i2Integration_EventRegv45_
Event e,i2Integration_EventRegv4
5_Registra
tion r where e.intEventID = r.intEventID and r.blnEmailSent=1 and (YEAR(e.dtmEvent) = '" + ddlYear.SelectedValue + "' AND MONTH(e.dtmEvent) = '" + ddlMth.SelectedValue + "' AND e.strTitle = '" + DroplistData.SelectedValue
.Tostring.
replace("'
","''") + "') Order by e.dtmEvent"
Using sqlConn As New SqlConnection(Configuratio
nManager.C
onnectionS
trings("Si
teSqlServe
r").Connec
tionString
)
Using adapPatientBills As New SqlDataAdapter(strSelectCo
mmand, sqlConn)
adapPatientBills.Fill(dtVo
lumeOrder)
End Using
End Using
iRowsCount = dtVolumeOrder.Rows.Count - 1
uxItemDetailGrid.DataSourc
e = dtVolumeOrder
uxItemDetailGrid.DataBind(
)
End Sub
Protected Sub ddlYear_SelectedIndexChang
ed(ByVal sender As Object, ByVal e As System.EventArgs)
'+ "' AND e.strTitle = '" + DroplistData.SelectedValue
Dim dtVolumeOrder As New DataTable()
Dim strSelectCommand As String = "SELECT e.dtmEvent,e.strTitle,r.st
rName, r.strNeeds, r.dtmCreated FROM i2Integration_EventRegv45_
Event e,i2Integration_EventRegv4
5_Registra
tion r where e.intEventID = r.intEventID and r.blnEmailSent=1 and (YEAR(e.dtmEvent) = '" + ddlYear.SelectedValue + "' AND MONTH(e.dtmEvent) = '" + ddlMth.SelectedValue + "' AND e.strTitle = '" + DroplistData.SelectedValue
.Tostring.
replace("'
","''") + "') Order by e.dtmEvent"
Using sqlConn As New SqlConnection(Configuratio
nManager.C
onnectionS
trings("Si
teSqlServe
r").Connec
tionString
)
Using adapPatientBills As New SqlDataAdapter(strSelectCo
mmand, sqlConn)
adapPatientBills.Fill(dtVo
lumeOrder)
End Using
End Using
iRowsCount = dtVolumeOrder.Rows.Count - 1
uxItemDetailGrid.DataSourc
e = dtVolumeOrder
uxItemDetailGrid.DataBind(
)
End Sub
Public Overloads Overrides Sub VerifyRenderingInServerFor
m(ByVal control As Control)
' Verifies that the control is rendered
End Sub
Protected Sub OnPaging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
uxItemDetailGrid.PageIndex
= e.NewPageIndex
uxItemDetailGrid.DataBind(
)
End Sub
Protected Sub btnReturn_Click(ByVal sender As Object, ByVal e As EventArgs)
'Dim URL = "
http://www.cmaanorcaleven
ts.com/
"
Response.Redirect("
http://
www.cmaano
rcalevents
.com
") ' return to clients website
End Sub
Protected Sub btnExportExcel_Click(ByVal
sender As Object, ByVal e As EventArgs)
Response.Clear()
Response.Buffer = True
'For Word:
'Response.AddHeader("conte
nt-disposi
tion", "attachment;filename=data.
doc")
'Response.ContentType = "application/vnd.ms-word"
'For Excel
Response.AddHeader("conten
t-disposit
ion", "attachment;filename=Meald
ata.xls")
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim oStringWriter As New System.IO.StringWriter()
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWrit
er(oString
Writer)
uxItemDetailGrid.RenderCon
trol(oHtml
TextWriter
)
Response.Write(oStringWrit
er.ToStrin
g())
Response.[End]()
End Sub
Protected Sub uxItemDetailGrid_RowUpdati
ng(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
Dim contact As New ContactTableAdapter()
Dim txtName As TextBox = DirectCast(uxItemDetailGri
d.Rows(e.R
owIndex).F
indControl
("strNeeds
"), TextBox)
contact.Update(txtName.Tex
t)
uxItemDetailGrid.EditIndex
= -1
FillGrid()
End Sub
Protected Sub uxItemDetailGrid_RowEditin
g(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
uxItemDetailGrid.EditIndex
= e.NewEditIndex
FillGrid()
End Sub
Protected Sub uxItemDetailGrid_RowCancel
ingEdit(By
Val sender As Object, ByVal e As GridViewCancelEditEventArg
s)
uxItemDetailGrid.EditIndex
= -1
FillGrid()
End Sub
Protected Sub uxItemDetailGrid_RowDeleti
ng(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs)
Dim contact As New ContactTableAdapter()
Dim id As Integer = Convert.ToInt32(uxItemDeta
ilGrid.Dat
aKeys(e.Ro
wIndex).Va
lues(0).To
String())
contact.Delete(id)
FillGrid()
End Sub
End Class
Answer : I am trying to add an edit, delete function to an existing gridview
can you also post your ContactTableAdapter class?
Random Solutions
SBS 2008 RWW Connect to Computer, will not authenticate
VB code doesn't work in ACCDE file
Is there a way to enable remote registry service on my clinets using group policy?
Terminal Server 2000 - disabling and/or capturing disconnecting
In-place upgrade of Hyper-V Server 2k8 R2 to Full Server 2k8 w/Hyper-v role
WHERE clause with DLookup
ie 6 display problem
How to represent a null in a string?
Access 2003 report to print labels
Get autonumber ( unique ID ) of newly inserted record, then insert value into a relating table, ms access 2003