473,714 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Controls inside EditTemplate cause editing to end

I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="up date", and a
Button with CommandName="ca ncel". Whenever I click one of these controls,
the DataList replaces the EditTemplate with the ItemTemplate. I think this
is because the method I wrote which performs the databinding is getting
called, but I don't know why or where it is getting called from. It does not
get called from my Page_Load method and I do not have an ItemCommand event
handler, so I don't know where to start testing for it. I tested to see if
my UpdateCommand event is getting called when I click the Button with
CommandName="up date" by assigning some text to a Label control, so I know
that it is never getting called. What could be causing my problem? Any help
would be appreciated. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
10 1495
Nathan,

Make certain that your DataList control has it's viewstate property set to
true and then, wherever in your code you are binding the DataList, wrap that
code in:

If Not IsPostBack Then
'---Bind your DataList here.
End If

I don't know exactly where you are doing your databinding, but from what you
describe I think you have identified your problem correctly. Your DataList
is getting re-bound on postback.

By the way, please don't post to more than one newsgroup at a time...
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="up date", and a
Button with CommandName="ca ncel". Whenever I click one of these controls,
the DataList replaces the EditTemplate with the ItemTemplate. I think this
is because the method I wrote which performs the databinding is getting
called, but I don't know why or where it is getting called from. It does
not get called from my Page_Load method and I do not have an ItemCommand
event handler, so I don't know where to start testing for it. I tested to
see if my UpdateCommand event is getting called when I click the Button
with CommandName="up date" by assigning some text to a Label control, so I
know that it is never getting called. What could be causing my problem? Any
help would be appreciated. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Nov 19 '05 #2
It's called from the Button's OnCommand event handler. The OnCommand is bubbled
up thru the part control hierarchy so child controls like the button can
send commands up to parent controls.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have a DataList control with an EditTemplate. Three of the controls
in this template include a Calendar, a Button with
CommandName="up date", and a Button with CommandName="ca ncel". Whenever
I click one of these controls, the DataList replaces the EditTemplate
with the ItemTemplate. I think this is because the method I wrote
which performs the databinding is getting called, but I don't know why
or where it is getting called from. It does not get called from my
Page_Load method and I do not have an ItemCommand event handler, so I
don't know where to start testing for it. I tested to see if my
UpdateCommand event is getting called when I click the Button with
CommandName="up date" by assigning some text to a Label control, so I
know that it is never getting called. What could be causing my
problem? Any help would be appreciated. Thanks.


Nov 19 '05 #3
My DataList's EnableViewState property is set to True. I have tried wrapping
my binding code in an If Not IsPostBack Then statement like you said, but
that causes the binding to not occur at other times when it does need to
happen. I have a method that contains my binding code which I call in my
Page_Init method as well as after I make any changes to the database I use
as my datasource. This method is as follows:

Private Sub RefreshEvents()

Dim events As New DataSet

Dim myconnection As New
OracleConnectio n(System.Config uration.Configu rationSettings. AppSettings("co nnectionString" ))

Dim cmdselect As New OracleCommand(" SELECT * FROM eventlist WHERE
eventdate<TO_DA TE('" & Date.Now.ToShor tDateString() & "','MM/DD/YYYY')",
myconnection)

Dim cmddelete As New OracleCommand(" ", myconnection)

Dim eventsadapter As New OracleDataAdapt er(cmdselect)

'Delete any past events and the people who registered for them

eventsadapter.F ill(events, "eventlist" )

If events.Tables(" eventlist").Row s.Count <> 0 Then

For Each pastevent As DataRow In events.Tables(" eventlist").Row s

cmddelete.Comma ndText = "DELETE FROM registered WHERE eventid=" &
pastevent.Item( "eventid")

myconnection.Op en()

cmddelete.Execu teNonQuery()

cmddelete.Comma ndText = "DELETE FROM eventlist WHERE eventid=" &
pastevent.Item( "eventid")

cmddelete.Execu teNonQuery()

myconnection.Cl ose()

If pastevent.Item( "details") <> "" AndAlso
System.IO.File. Exists(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) ) Then
System.IO.File. Delete(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) )

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.Comma ndText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.S electCommand = cmdselect

eventsadapter.F ill(events, "eventlist" )

datEditEvents.D ataSource = events

datEditEvents.D ataBind()

ddlDeleteEvents .Items.Clear()

For Each existevent As DataRow In events.Tables(" eventlist").Row s

ddlDeleteEvents .Items.Add(New
ListItem(CDate( existevent("eve ntdate")).ToSho rtDateString() & " " &
existevent("eve ntname"), existevent("eve ntid")))

Next

End Sub
Any other ideas? If you would like to see any of the other code I use, just
let me know. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:uX******** ******@tk2msftn gp13.phx.gbl...
Nathan,

Make certain that your DataList control has it's viewstate property set to
true and then, wherever in your code you are binding the DataList, wrap
that code in:

If Not IsPostBack Then
'---Bind your DataList here.
End If

I don't know exactly where you are doing your databinding, but from what
you describe I think you have identified your problem correctly. Your
DataList is getting re-bound on postback.

By the way, please don't post to more than one newsgroup at a time...
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="up date", and
a Button with CommandName="ca ncel". Whenever I click one of these
controls, the DataList replaces the EditTemplate with the ItemTemplate. I
think this is because the method I wrote which performs the databinding is
getting called, but I don't know why or where it is getting called from.
It does not get called from my Page_Load method and I do not have an
ItemCommand event handler, so I don't know where to start testing for it.
I tested to see if my UpdateCommand event is getting called when I click
the Button with CommandName="up date" by assigning some text to a Label
control, so I know that it is never getting called. What could be causing
my problem? Any help would be appreciated. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/


Nov 19 '05 #4
If that were true, why was my test code of assigning some text to a Label
not being called? Also, that still does not explain why the Calendar was
doing what it was doing. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:11******** *************** @msnews.microso ft.com...
It's called from the Button's OnCommand event handler. The OnCommand is
bubbled up thru the part control hierarchy so child controls like the
button can send commands up to parent controls.
-Brock
DevelopMentor
http://staff.develop.com/ballen
I have a DataList control with an EditTemplate. Three of the controls
in this template include a Calendar, a Button with
CommandName="up date", and a Button with CommandName="ca ncel". Whenever
I click one of these controls, the DataList replaces the EditTemplate
with the ItemTemplate. I think this is because the method I wrote
which performs the databinding is getting called, but I don't know why
or where it is getting called from. It does not get called from my
Page_Load method and I do not have an ItemCommand event handler, so I
don't know where to start testing for it. I tested to see if my
UpdateCommand event is getting called when I click the Button with
CommandName="up date" by assigning some text to a Label control, so I
know that it is never getting called. What could be causing my
problem? Any help would be appreciated. Thanks.


Nov 19 '05 #5
Leave the if then and then call the binding code when you need to from those
methods.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:O6******** *****@TK2MSFTNG P15.phx.gbl...
My DataList's EnableViewState property is set to True. I have tried
wrapping my binding code in an If Not IsPostBack Then statement like you
said, but that causes the binding to not occur at other times when it does
need to happen. I have a method that contains my binding code which I call
in my Page_Init method as well as after I make any changes to the database
I use as my datasource. This method is as follows:

Private Sub RefreshEvents()

Dim events As New DataSet

Dim myconnection As New
OracleConnectio n(System.Config uration.Configu rationSettings. AppSettings("co nnectionString" ))

Dim cmdselect As New OracleCommand(" SELECT * FROM eventlist WHERE
eventdate<TO_DA TE('" & Date.Now.ToShor tDateString() & "','MM/DD/YYYY')",
myconnection)

Dim cmddelete As New OracleCommand(" ", myconnection)

Dim eventsadapter As New OracleDataAdapt er(cmdselect)

'Delete any past events and the people who registered for them

eventsadapter.F ill(events, "eventlist" )

If events.Tables(" eventlist").Row s.Count <> 0 Then

For Each pastevent As DataRow In events.Tables(" eventlist").Row s

cmddelete.Comma ndText = "DELETE FROM registered WHERE eventid=" &
pastevent.Item( "eventid")

myconnection.Op en()

cmddelete.Execu teNonQuery()

cmddelete.Comma ndText = "DELETE FROM eventlist WHERE eventid=" &
pastevent.Item( "eventid")

cmddelete.Execu teNonQuery()

myconnection.Cl ose()

If pastevent.Item( "details") <> "" AndAlso
System.IO.File. Exists(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) ) Then
System.IO.File. Delete(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) )

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.Comma ndText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.S electCommand = cmdselect

eventsadapter.F ill(events, "eventlist" )

datEditEvents.D ataSource = events

datEditEvents.D ataBind()

ddlDeleteEvents .Items.Clear()

For Each existevent As DataRow In events.Tables(" eventlist").Row s

ddlDeleteEvents .Items.Add(New
ListItem(CDate( existevent("eve ntdate")).ToSho rtDateString() & " " &
existevent("eve ntname"), existevent("eve ntid")))

Next

End Sub
Any other ideas? If you would like to see any of the other code I use,
just let me know. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:uX******** ******@tk2msftn gp13.phx.gbl...
Nathan,

Make certain that your DataList control has it's viewstate property set
to true and then, wherever in your code you are binding the DataList,
wrap that code in:

If Not IsPostBack Then
'---Bind your DataList here.
End If

I don't know exactly where you are doing your databinding, but from what
you describe I think you have identified your problem correctly. Your
DataList is getting re-bound on postback.

By the way, please don't post to more than one newsgroup at a time...
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="up date", and
a Button with CommandName="ca ncel". Whenever I click one of these
controls, the DataList replaces the EditTemplate with the ItemTemplate. I
think this is because the method I wrote which performs the databinding
is getting called, but I don't know why or where it is getting called
from. It does not get called from my Page_Load method and I do not have
an ItemCommand event handler, so I don't know where to start testing for
it. I tested to see if my UpdateCommand event is getting called when I
click the Button with CommandName="up date" by assigning some text to a
Label control, so I know that it is never getting called. What could be
causing my problem? Any help would be appreciated. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/



Nov 19 '05 #6
I think you misunderstood what I meant. If I were to use the If Then like
you said, the If Then would have to go inside my RefreshEvents() method,
since that is the only place that I know is getting called during the
"undesired" databinding. However, if I did that, it would affect the
databinding when I don't want it to just like when I had the problem before.
If I knew where the "undesired" databinding was being called from (in other
words, what method calls RefreshEvents() when I don't want it to) I could
put the If Then there, but I don't know where that is. Another solution, if
it exists, would be to use an If Then with a condition based on what method
was calling it. Any ideas? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:uF******** ******@TK2MSFTN GP11.phx.gbl...
Leave the if then and then call the binding code when you need to from
those methods.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:O6******** *****@TK2MSFTNG P15.phx.gbl...
My DataList's EnableViewState property is set to True. I have tried
wrapping my binding code in an If Not IsPostBack Then statement like you
said, but that causes the binding to not occur at other times when it
does need to happen. I have a method that contains my binding code which
I call in my Page_Init method as well as after I make any changes to the
database I use as my datasource. This method is as follows:

Private Sub RefreshEvents()

Dim events As New DataSet

Dim myconnection As New
OracleConnectio n(System.Config uration.Configu rationSettings. AppSettings("co nnectionString" ))

Dim cmdselect As New OracleCommand(" SELECT * FROM eventlist WHERE
eventdate<TO_DA TE('" & Date.Now.ToShor tDateString() & "','MM/DD/YYYY')",
myconnection)

Dim cmddelete As New OracleCommand(" ", myconnection)

Dim eventsadapter As New OracleDataAdapt er(cmdselect)

'Delete any past events and the people who registered for them

eventsadapter.F ill(events, "eventlist" )

If events.Tables(" eventlist").Row s.Count <> 0 Then

For Each pastevent As DataRow In events.Tables(" eventlist").Row s

cmddelete.Comma ndText = "DELETE FROM registered WHERE eventid=" &
pastevent.Item( "eventid")

myconnection.Op en()

cmddelete.Execu teNonQuery()

cmddelete.Comma ndText = "DELETE FROM eventlist WHERE eventid=" &
pastevent.Item( "eventid")

cmddelete.Execu teNonQuery()

myconnection.Cl ose()

If pastevent.Item( "details") <> "" AndAlso
System.IO.File. Exists(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) ) Then
System.IO.File. Delete(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) )

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.Comma ndText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.S electCommand = cmdselect

eventsadapter.F ill(events, "eventlist" )

datEditEvents.D ataSource = events

datEditEvents.D ataBind()

ddlDeleteEvents .Items.Clear()

For Each existevent As DataRow In events.Tables(" eventlist").Row s

ddlDeleteEvents .Items.Add(New
ListItem(CDate( existevent("eve ntdate")).ToSho rtDateString() & " " &
existevent("eve ntname"), existevent("eve ntid")))

Next

End Sub
Any other ideas? If you would like to see any of the other code I use,
just let me know. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:uX******** ******@tk2msftn gp13.phx.gbl...
Nathan,

Make certain that your DataList control has it's viewstate property set
to true and then, wherever in your code you are binding the DataList,
wrap that code in:

If Not IsPostBack Then
'---Bind your DataList here.
End If

I don't know exactly where you are doing your databinding, but from what
you describe I think you have identified your problem correctly. Your
DataList is getting re-bound on postback.

By the way, please don't post to more than one newsgroup at a time...
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="up date",
and a Button with CommandName="ca ncel". Whenever I click one of these
controls, the DataList replaces the EditTemplate with the ItemTemplate.
I think this is because the method I wrote which performs the
databindi ng is getting called, but I don't know why or where it is
getting called from. It does not get called from my Page_Load method and
I do not have an ItemCommand event handler, so I don't know where to
start testing for it. I tested to see if my UpdateCommand event is
getting called when I click the Button with CommandName="up date" by
assigning some text to a Label control, so I know that it is never
getting called. What could be causing my problem? Any help would be
appreciated . Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/



Nov 19 '05 #7
Nathan,

You've got the solution at hand. You need to identify the undesired call(s)
to RefreshEvents() and put the If Then there.

That's really the only way to do it. If you're using Visual Studio now is
the time to set a breakpoint and see exactly what your code is doing...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I think you misunderstood what I meant. If I were to use the If Then like
you said, the If Then would have to go inside my RefreshEvents() method,
since that is the only place that I know is getting called during the
"undesired" databinding. However, if I did that, it would affect the
databinding when I don't want it to just like when I had the problem
before. If I knew where the "undesired" databinding was being called from
(in other words, what method calls RefreshEvents() when I don't want it to)
I could put the If Then there, but I don't know where that is. Another
solution, if it exists, would be to use an If Then with a condition based
on what method was calling it. Any ideas? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:uF******** ******@TK2MSFTN GP11.phx.gbl...
Leave the if then and then call the binding code when you need to from
those methods.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:O6******** *****@TK2MSFTNG P15.phx.gbl...
My DataList's EnableViewState property is set to True. I have tried
wrapping my binding code in an If Not IsPostBack Then statement like you
said, but that causes the binding to not occur at other times when it
does need to happen. I have a method that contains my binding code which
I call in my Page_Init method as well as after I make any changes to the
database I use as my datasource. This method is as follows:

Private Sub RefreshEvents()

Dim events As New DataSet

Dim myconnection As New
OracleConnectio n(System.Config uration.Configu rationSettings. AppSettings("co nnectionString" ))

Dim cmdselect As New OracleCommand(" SELECT * FROM eventlist WHERE
eventdate<TO_DA TE('" & Date.Now.ToShor tDateString() & "','MM/DD/YYYY')",
myconnection)

Dim cmddelete As New OracleCommand(" ", myconnection)

Dim eventsadapter As New OracleDataAdapt er(cmdselect)

'Delete any past events and the people who registered for them

eventsadapter.F ill(events, "eventlist" )

If events.Tables(" eventlist").Row s.Count <> 0 Then

For Each pastevent As DataRow In events.Tables(" eventlist").Row s

cmddelete.Comma ndText = "DELETE FROM registered WHERE eventid=" &
pastevent.Item( "eventid")

myconnection.Op en()

cmddelete.Execu teNonQuery()

cmddelete.Comma ndText = "DELETE FROM eventlist WHERE eventid=" &
pastevent.Item( "eventid")

cmddelete.Execu teNonQuery()

myconnection.Cl ose()

If pastevent.Item( "details") <> "" AndAlso
System.IO.File. Exists(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) ) Then
System.IO.File. Delete(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) )

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.Comma ndText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.S electCommand = cmdselect

eventsadapter.F ill(events, "eventlist" )

datEditEvents.D ataSource = events

datEditEvents.D ataBind()

ddlDeleteEvents .Items.Clear()

For Each existevent As DataRow In events.Tables(" eventlist").Row s

ddlDeleteEvents .Items.Add(New
ListItem(CDate( existevent("eve ntdate")).ToSho rtDateString() & " " &
existevent("eve ntname"), existevent("eve ntid")))

Next

End Sub
Any other ideas? If you would like to see any of the other code I use,
just let me know. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:uX******** ******@tk2msftn gp13.phx.gbl...
Nathan,

Make certain that your DataList control has it's viewstate property set
to true and then, wherever in your code you are binding the DataList,
wrap that code in:

If Not IsPostBack Then
'---Bind your DataList here.
End If

I don't know exactly where you are doing your databinding, but from
what you describe I think you have identified your problem correctly.
Your DataList is getting re-bound on postback.

By the way, please don't post to more than one newsgroup at a time...
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
>I have a DataList control with an EditTemplate. Three of the controls
>in this template include a Calendar, a Button with
>CommandNam e="update", and a Button with CommandName="ca ncel". Whenever
>I click one of these controls, the DataList replaces the EditTemplate
>with the ItemTemplate. I think this is because the method I wrote which
>performs the databinding is getting called, but I don't know why or
>where it is getting called from. It does not get called from my
>Page_Loa d method and I do not have an ItemCommand event handler, so I
>don't know where to start testing for it. I tested to see if my
>UpdateComm and event is getting called when I click the Button with
>CommandNam e="update" by assigning some text to a Label control, so I
>know that it is never getting called. What could be causing my problem?
>Any help would be appreciated. Thanks.
> --
> Nathan Sokalski
> nj********@hotm ail.com
> http://www.nathansokalski.com/
>



Nov 19 '05 #8
I would like to set a breakpoint in Visual Studio to find the undesired
call, but unfortunately the site is on a remote server and according to the
person in charge of the server (who is also the person who taught me
ASP.NET) the server's ability to do debugging remotely has been turned off.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:O0******** ******@TK2MSFTN GP10.phx.gbl...
Nathan,

You've got the solution at hand. You need to identify the undesired
call(s) to RefreshEvents() and put the If Then there.

That's really the only way to do it. If you're using Visual Studio now is
the time to set a breakpoint and see exactly what your code is doing...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I think you misunderstood what I meant. If I were to use the If Then like
you said, the If Then would have to go inside my RefreshEvents() method,
since that is the only place that I know is getting called during the
"undesired" databinding. However, if I did that, it would affect the
databinding when I don't want it to just like when I had the problem
before. If I knew where the "undesired" databinding was being called from
(in other words, what method calls RefreshEvents() when I don't want it
to) I could put the If Then there, but I don't know where that is. Another
solution, if it exists, would be to use an If Then with a condition based
on what method was calling it. Any ideas? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:uF******** ******@TK2MSFTN GP11.phx.gbl...
Leave the if then and then call the binding code when you need to from
those methods.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:O6******** *****@TK2MSFTNG P15.phx.gbl...
My DataList's EnableViewState property is set to True. I have tried
wrapping my binding code in an If Not IsPostBack Then statement like
you said, but that causes the binding to not occur at other times when
it does need to happen. I have a method that contains my binding code
which I call in my Page_Init method as well as after I make any changes
to the database I use as my datasource. This method is as follows:

Private Sub RefreshEvents()

Dim events As New DataSet

Dim myconnection As New
OracleConnectio n(System.Config uration.Configu rationSettings. AppSettings("co nnectionString" ))

Dim cmdselect As New OracleCommand(" SELECT * FROM eventlist WHERE
eventdate<TO_DA TE('" & Date.Now.ToShor tDateString() &
"','MM/DD/YYYY')", myconnection)

Dim cmddelete As New OracleCommand(" ", myconnection)

Dim eventsadapter As New OracleDataAdapt er(cmdselect)

'Delete any past events and the people who registered for them

eventsadapter.F ill(events, "eventlist" )

If events.Tables(" eventlist").Row s.Count <> 0 Then

For Each pastevent As DataRow In events.Tables(" eventlist").Row s

cmddelete.Comma ndText = "DELETE FROM registered WHERE eventid=" &
pastevent.Item( "eventid")

myconnection.Op en()

cmddelete.Execu teNonQuery()

cmddelete.Comma ndText = "DELETE FROM eventlist WHERE eventid=" &
pastevent.Item( "eventid")

cmddelete.Execu teNonQuery()

myconnection.Cl ose()

If pastevent.Item( "details") <> "" AndAlso
System.IO.File. Exists(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) ) Then
System.IO.File. Delete(Server.M apPath("eventde tails/" &
pastevent.Item( "details")) )

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.Comma ndText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.S electCommand = cmdselect

eventsadapter.F ill(events, "eventlist" )

datEditEvents.D ataSource = events

datEditEvents.D ataBind()

ddlDeleteEvents .Items.Clear()

For Each existevent As DataRow In events.Tables(" eventlist").Row s

ddlDeleteEvents .Items.Add(New
ListItem(CDate( existevent("eve ntdate")).ToSho rtDateString() & " " &
existevent("eve ntname"), existevent("eve ntid")))

Next

End Sub
Any other ideas? If you would like to see any of the other code I use,
just let me know. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:uX******** ******@tk2msftn gp13.phx.gbl...
> Nathan,
>
> Make certain that your DataList control has it's viewstate property
> set to true and then, wherever in your code you are binding the
> DataList, wrap that code in:
>
> If Not IsPostBack Then
> '---Bind your DataList here.
> End If
>
> I don't know exactly where you are doing your databinding, but from
> what you describe I think you have identified your problem correctly.
> Your DataList is getting re-bound on postback.
>
> By the way, please don't post to more than one newsgroup at a time...
>
>
> --
> Sincerely,
>
> S. Justin Gengo, MCP
> Web Developer / Programmer
>
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzsche
> "Nathan Sokalski" <nj********@hot mail.com> wrote in message
> news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
>>I have a DataList control with an EditTemplate. Three of the controls
>>in this template include a Calendar, a Button with
>>CommandNa me="update", and a Button with CommandName="ca ncel". Whenever
>>I click one of these controls, the DataList replaces the EditTemplate
>>with the ItemTemplate. I think this is because the method I wrote
>>which performs the databinding is getting called, but I don't know why
>>or where it is getting called from. It does not get called from my
>>Page_Lo ad method and I do not have an ItemCommand event handler, so I
>>don't know where to start testing for it. I tested to see if my
>>UpdateCom mand event is getting called when I click the Button with
>>CommandNa me="update" by assigning some text to a Label control, so I
>>know that it is never getting called. What could be causing my
>>problem ? Any help would be appreciated. Thanks.
>> --
>> Nathan Sokalski
>> nj********@hotm ail.com
>> http://www.nathansokalski.com/
>>
>
>



Nov 19 '05 #9
Hmmmm,

That's going to make it hard to identify...

What type of system are you on? I develop all my code on a Windows XP Pro
system running iis locally, then I deploy the code to a development server
for testing, Staging for more real-world testing, and finally production.

Can you set up your project to run locally and debug there?

Otherwise you're going to have to just really look at your code carefully...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I would like to set a breakpoint in Visual Studio to find the undesired
call, but unfortunately the site is on a remote server and according to the
person in charge of the server (who is also the person who taught me
ASP.NET) the server's ability to do debugging remotely has been turned off.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:O0******** ******@TK2MSFTN GP10.phx.gbl...
Nathan,

You've got the solution at hand. You need to identify the undesired
call(s) to RefreshEvents() and put the If Then there.

That's really the only way to do it. If you're using Visual Studio now is
the time to set a breakpoint and see exactly what your code is doing...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I think you misunderstood what I meant. If I were to use the If Then like
you said, the If Then would have to go inside my RefreshEvents() method,
since that is the only place that I know is getting called during the
"undesired " databinding. However, if I did that, it would affect the
databindin g when I don't want it to just like when I had the problem
before. If I knew where the "undesired" databinding was being called from
(in other words, what method calls RefreshEvents() when I don't want it
to) I could put the If Then there, but I don't know where that is.
Another solution, if it exists, would be to use an If Then with a
condition based on what method was calling it. Any ideas? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote in
message news:uF******** ******@TK2MSFTN GP11.phx.gbl...
Leave the if then and then call the binding code when you need to from
those methods.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:O6******** *****@TK2MSFTNG P15.phx.gbl...
> My DataList's EnableViewState property is set to True. I have tried
> wrapping my binding code in an If Not IsPostBack Then statement like
> you said, but that causes the binding to not occur at other times when
> it does need to happen. I have a method that contains my binding code
> which I call in my Page_Init method as well as after I make any
> changes to the database I use as my datasource. This method is as
> follows:
>
> Private Sub RefreshEvents()
>
> Dim events As New DataSet
>
> Dim myconnection As New
> OracleConnectio n(System.Config uration.Configu rationSettings. AppSettings("co nnectionString" ))
>
> Dim cmdselect As New OracleCommand(" SELECT * FROM eventlist WHERE
> eventdate<TO_DA TE('" & Date.Now.ToShor tDateString() &
> "','MM/DD/YYYY')", myconnection)
>
> Dim cmddelete As New OracleCommand(" ", myconnection)
>
> Dim eventsadapter As New OracleDataAdapt er(cmdselect)
>
> 'Delete any past events and the people who registered for them
>
> eventsadapter.F ill(events, "eventlist" )
>
> If events.Tables(" eventlist").Row s.Count <> 0 Then
>
> For Each pastevent As DataRow In events.Tables(" eventlist").Row s
>
> cmddelete.Comma ndText = "DELETE FROM registered WHERE eventid=" &
> pastevent.Item( "eventid")
>
> myconnection.Op en()
>
> cmddelete.Execu teNonQuery()
>
> cmddelete.Comma ndText = "DELETE FROM eventlist WHERE eventid=" &
> pastevent.Item( "eventid")
>
> cmddelete.Execu teNonQuery()
>
> myconnection.Cl ose()
>
> If pastevent.Item( "details") <> "" AndAlso
> System.IO.File. Exists(Server.M apPath("eventde tails/" &
> pastevent.Item( "details")) ) Then
> System.IO.File. Delete(Server.M apPath("eventde tails/" &
> pastevent.Item( "details")) )
>
> Next
>
> End If
>
> 'Fill DataSet with all remaining events
>
> events.Clear()
>
> cmdselect.Comma ndText = "SELECT * FROM eventlist ORDER BY eventdate"
>
> eventsadapter.S electCommand = cmdselect
>
> eventsadapter.F ill(events, "eventlist" )
>
> datEditEvents.D ataSource = events
>
> datEditEvents.D ataBind()
>
> ddlDeleteEvents .Items.Clear()
>
> For Each existevent As DataRow In events.Tables(" eventlist").Row s
>
> ddlDeleteEvents .Items.Add(New
> ListItem(CDate( existevent("eve ntdate")).ToSho rtDateString() & " " &
> existevent("eve ntname"), existevent("eve ntid")))
>
> Next
>
> End Sub
>
>
> Any other ideas? If you would like to see any of the other code I use,
> just let me know. Thanks.
> --
> Nathan Sokalski
> nj********@hotm ail.com
> http://www.nathansokalski.com/
>
> "S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate. com> wrote
> in message news:uX******** ******@tk2msftn gp13.phx.gbl...
>> Nathan,
>>
>> Make certain that your DataList control has it's viewstate property
>> set to true and then, wherever in your code you are binding the
>> DataList, wrap that code in:
>>
>> If Not IsPostBack Then
>> '---Bind your DataList here.
>> End If
>>
>> I don't know exactly where you are doing your databinding, but from
>> what you describe I think you have identified your problem correctly.
>> Your DataList is getting re-bound on postback.
>>
>> By the way, please don't post to more than one newsgroup at a time...
>>
>>
>> --
>> Sincerely,
>>
>> S. Justin Gengo, MCP
>> Web Developer / Programmer
>>
>> www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>> "Nathan Sokalski" <nj********@hot mail.com> wrote in message
>> news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
>>>I have a DataList control with an EditTemplate. Three of the controls
>>>in this template include a Calendar, a Button with
>>>CommandN ame="update", and a Button with CommandName="ca ncel".
>>>Whenev er I click one of these controls, the DataList replaces the
>>>EditTemp late with the ItemTemplate. I think this is because the
>>>method I wrote which performs the databinding is getting called, but
>>>I don't know why or where it is getting called from. It does not get
>>>called from my Page_Load method and I do not have an ItemCommand
>>>event handler, so I don't know where to start testing for it. I
>>>tested to see if my UpdateCommand event is getting called when I
>>>click the Button with CommandName="up date" by assigning some text to
>>>a Label control, so I know that it is never getting called. What
>>>could be causing my problem? Any help would be appreciated. Thanks.
>>> --
>>> Nathan Sokalski
>>> nj********@hotm ail.com
>>> http://www.nathansokalski.com/
>>>
>>
>>
>
>



Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1726
by: Renato Neves | last post by:
My problem is simple, i have a datalist control with some controls inside of EditTemplate (the problem is the same in the DataGrid). I want to have access to this controls, using javascript, but i can't. How can i do this? <Code> <script language="javascript"> document.getElementById('<%=txt1.ClientID %>').value='test'; document.getElementById('<%=txt2.ClientID %>').value='test';
5
1331
by: Dranreb | last post by:
Hello, I use a template whereby my default page contains various user controls - i.e. "Header", "Footer", "Navigation", "Content". On some occaisions I'd like to manipulate the other controls from the content control, without refreshing the default page. Currently, to change the content I refresh the default page by doing a response.redirect and referencing the new content page in the querystring. My default page includes the...
3
1879
by: Scott at Cedar Creek | last post by:
Can I put a repeater inside a FormView? Can I put a repeater inside that repeater? If so, what happens when the FormView.Mode is "Edit?" When they click the EDIT button is my repeater data also saved? Or do I have to code that manually? Thanks in advance, Scott
0
2129
by: JohnyStyles | last post by:
I have a templated user control which looks like this: ----------------------------------------------------------------- <uc:MyUserControl runat=server> <TemplateProperty> </TemplateProperty> </uc:MyUserControl> -----------------------------------------------------------------
15
2185
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) Dim dSet As DataSet Dim sqlConn As SqlConnection Dim sqlDapter As SqlDataAdapter sqlConn = New SqlConnection("Data Source=AD\SQLEXPRESS;Initial
4
15022
by: John Dalberg | last post by:
I am looking at a problem which is preventing my code to get a reference to any asp control inside a div section which has a runat=server attribute. This can be reproduced in a simple test: Create a blank webform and add this html inside the <formsection: <div id="myDiv" runat=server> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </div> In the code behind, add this code in the page_load event handler:
4
2697
by: TS | last post by:
Steven, i lost this message conversation from outlook express and made a post online (see last one on this page). Please answer it as it hasn't been yet. thanks The clientID of our controls have become very long since we have 2 master pages that our pages inherit from. Some team members at
1
2166
by: Aamir Ghanchi | last post by:
Like thr subject line says. I get no intellisense in VS 2005 as well as get the compilation message "The name 'ddlCourse1' does not exist in the current context". Is there a way to have access to the controls being validated in the EditTemplate of gridview. The CustomValidator control itself is outside the gridview, but I have tried putting it in a template column of gridview alongside with Edit/ Update linked buttons but to no avail. ...
0
877
by: =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= | last post by:
How can I display a different control for my in my table, inside an ItemTemplate or EditTemplate, depending on the value of another column, the , which has values like 'STRING', 'INTEGER', 'BOOLEAN', 'DECIMAL', 'DATETIME', 'MONEY', 'SQL_LIST_VALUES'? That is, if the in a specific gridview row, has a value of 'BOOLEAN', then I want my to display a checkbox in ItemTemplate or EditTemplate and not a textbox. Also, when the is...
0
8801
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7953
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5947
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3158
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2520
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2110
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.