I have an aspx page where I use a reversebind and
templates to edit the entire datagrid at one time. I
added a textbox and button to change the parameter
criteria and then rerun the databind2 procedure. That
works fine the data is requeried and the new results are
displayed in the datagrid and the reversebind works for
saving the information. However if I add another text
box or dropdown box it does not seem to requery
correctly. If I remove the reversebind it will, but
without the reversebind I can not save changes to the
datagrid as a whole. I think I understand why using the
ddcp.selectedin dex change sub will not work because it is
posting back however I can not figure out why adding an
additional text box for input and placing that within the
button1 command is not. I have looked at the stored
procedure also. I need to be able to either look at all
or a particular type of cp. I would prefer to use a drop
down box either inside or out of the button1 command.
Any help would appreciated. Thanks in advance
Here is both the code for page and stored_proc. page
also draws really slow:
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
datcurrent = Date.Now.ToShor tDateString
lblselectedcald t.Text = DateAdd
(DateInterval.D ay, 1, datcurrent)
squad = Request.QuerySt ring("usersquad ")
lblusersquad.Te xt = squad
lblselectedCP.T ext = ddcp.SelectedVa lue
BindData2()
lbltoday.Text = datcurrent
txtdaysout.Text = ""
Else
ReverseBind()
End If
End Sub
Sub BindData2()
Dim cp As String
'cp = "c"
'If ddcp.SelectedIn dex > -1 Then
cp = lblselectedCP.T ext
'ElseIf ddcp.SelectedIn dex = -1 Then
' cp = "%"
'End If
'If lblselectedCP.T ext = "" Then
'cp = "%"
'Else
' cp = lblselectedCP.T ext
'End If
sdate = CType(lblselect edcaldt.Text, DateTime)
If lbl4days.Text = "" Then
daysout = 36
Else
daysout = CType(lbl4days. Text, Integer)
End If
'squad = lblusersquad.Te xt
SqlSelectComman d1.Parameters(" @sdate").Value =
sdate
SqlSelectComman d1.Parameters(" @time").Value =
daysout
SqlSelectComman d1.Parameters(" @squad").Value =
lblusersquad.Te xt
If lblselectedCP.T ext = "All" Then
SqlSelectComman d1.Parameters(" @cp").Value
= "%"
Else
SqlSelectComman d1.Parameters(" @cp").Value =
lblselectedCP.T ext
End If
'SqlConnection1 .Open()
SqlDataAdapter2 .Fill(DsCrewNot ify1)
DataGrid2.DataB ind()
_LastEditedPage = DataGrid2.Curre ntPageIndex
'SqlConnection1 .Close()
End Sub
Public Sub ReverseBind()
Dim gridrow As DataGridItem
Dim datarow As dsCrewNotify.og _getCrewNotifyR ow
For Each gridrow In DataGrid2.Items
datarow = DsCrewNotify1.o g_getCrewNotify
(gridrow.DataSe tIndex)
datarow.notifie d() = CType(gridrow.F indControl
("chkNotify" ), CheckBox).Check ed
DsCrewNotify1.o g_getCrewNotify
(gridrow.DataSe tIndex).ItemArr ay = datarow.ItemArr ay
Next
End Sub
Protected Overrides Sub LoadViewState(B yVal
savedstate As Object)
MyBase.LoadView State(savedstat e)
If (Not Me.ViewState("D ata") Is Nothing) Then
DsCrewNotify1 = CType(Me.ViewSt ate("Data"),
dsCrewNotify)
End If
If (Not Me.ViewState("L astEditedPage") Is
Nothing) Then
_LastEditedPage = CType(Me.ViewSt ate
("LastEditedPag e"), Integer)
End If
End Sub
Protected Overrides Function saveViewState() As Object
Me.ViewState("D ata") = DsCrewNotify1
Me.ViewState("L astEditedPage") = _LastEditedPage
Return (MyBase.SaveVie wState())
End Function
Private Sub DataGrid1_ItemD ataBound(ByVal sender As
Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
DataGrid2.ItemD ataBound
If (e.Item.ItemTyp e = ListItemType.It em Or
e.Item.ItemType = ListItemType.Al ternatingItem) Then
Dim datarow As
dsCrewNotify.og _getCrewNotifyR ow
datarow = CType(CType(e.I tem.DataItem,
DataRowView).Ro w, dsCrewNotify.og _getCrewNotifyR ow)
CType(e.Item.Fi ndControl("chkN otify"),
CheckBox).Check ed = datarow.notifie d
End If
End Sub
Sub updateData()
Dim gridrow As DataGridItem
Dim datarow As dsCrewNotify.og _getCrewNotifyR ow
Dim dscrewnotify As DataSet
Dim chkbox As CheckBox
Dim strnotify As String
Dim intid As Integer
For Each gridrow In DataGrid2.Items
datarow = DsCrewNotify1.o g_getCrewNotify
(gridrow.DataSe tIndex)
intid = datarow.Item(0)
datarow.notifie d() = CType(gridrow.F indControl
("chknotify" ), CheckBox).Check ed
DsCrewNotify1.o g_getCrewNotify
(gridrow.DataSe tIndex).ItemArr ay = datarow.ItemArr ay
strnotify = CType(gridrow.F indControl
("chkNotify" ), CheckBox).Check ed
SqlUpdateComman d1.Parameters(" @notify").Value
= strnotify
SqlUpdateComman d1.Parameters
("@schedid").Va lue = intid
SqlConnection1. Open()
SqlUpdateComman d1.ExecuteNonQu ery()
SqlConnection1. Close()
Next
'BindData2()
ReverseBind()
End Sub
Sub doUpdate(ByVal sender As Object, ByVal e As
DataGridCommand EventArgs)
If e.CommandName = "Update" Then
DataGrid2.Allow Paging = False
' DataGrid2.Allow Sorting = True
DataGrid2.DataS ource =
DsCrewNotify1.o g_getCrewNotify
ReverseBind()
updateData()
End If
End Sub
Private Sub Button1_Click(B yVal sender As
System.Object, ByVal e As System.EventArg s) Handles
Button1.Click
Dim numhours As Integer
If txtdaysout.Text = "" Then
numhours = 36
Else
numhours = (CType(txtdayso ut.Text, Integer) *
24) + 12
End If
' numhours = (CType(txtdayso ut.Text, Integer) *
24) + 12
lbl4days.Text = numhours
BindData2()
End Sub
Sub ddcp_SelectedIn dexChanged(ByVa l sender As Object,
ByVal e As System.EventArg s) Handles
ddcp.SelectedIn dexChanged
If ddcp.SelectedIn dex > -1 Then
lblselectedCP.T ext = ddcp.SelectedVa lue
BindData2()
End If
End Sub
End Class
Stored Proc::
CREATE PROCEDURE *********
@sdate as datetime
, @time as int
, @squad as nvarchar(10)
, @cp as nvarchar(10)
AS
Select
s.scheduleid
, s.namelast
, s.namefirst
, s.startdate
, s.stopdate
, s.notified
, e.mission_id
, e.eventName
, e.eventtype
, dateadd(hh,-5,e.alerttime) as alertime
, dateadd(hh, -5,e.showtime) as showtime
, et.EventCat
, e.eventsquadron
, e.eventsid
, e.eventtitle
, p.phonehome
, p.phonecell
, cp.crw_pstn_dty _cd
--, a.FLYR_ORG_UNIT _ID
--, a.person_id
From ****** as p
join ***** s
on p.ssn = s.ssn
join ***** e
on s.eventsid = e.eventsid
join ****** et
on e.eventtype = et.eventtypelon g
left join ******* a
on a.person_id = p.ssn
left join ******* cp
on a.person_id = cp.person_id
Where
--((dateadd(hh, -5,e.startdate)) between @sdate and
(dateadd(hh,36, @sdate)))
(dateadd(hh,-5,e.alerttime) between @sdate and (dateadd
(hh,@time,@sdat e)))
and substring(a.FLY R_ORG_UNIT_ID,1 ,4) like @squad
and cp.arcft_asg_ev t_id = '01'
and cp.crw_pstn_dty _cd like @cp
order by e.alerttime,e.e venttitle,s.nam elast
GO