By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

Controls inside EditTemplate cause editing to end

P: n/a
I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="update", and a
Button with CommandName="cancel". 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="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********@hotmail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="update", and a
Button with CommandName="cancel". 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="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********@hotmail.com
http://www.nathansokalski.com/

Nov 19 '05 #2

P: n/a
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="update", and a Button with CommandName="cancel". 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="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.


Nov 19 '05 #3

P: n/a
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
OracleConnection(System.Configuration.Configuratio nSettings.AppSettings("connectionString"))

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

Dim cmddelete As New OracleCommand("", myconnection)

Dim eventsadapter As New OracleDataAdapter(cmdselect)

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

eventsadapter.Fill(events, "eventlist")

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

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

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

myconnection.Open()

cmddelete.ExecuteNonQuery()

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

cmddelete.ExecuteNonQuery()

myconnection.Close()

If pastevent.Item("details") <> "" AndAlso
System.IO.File.Exists(Server.MapPath("eventdetails/" &
pastevent.Item("details"))) Then
System.IO.File.Delete(Server.MapPath("eventdetails/" &
pastevent.Item("details")))

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.CommandText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.SelectCommand = cmdselect

eventsadapter.Fill(events, "eventlist")

datEditEvents.DataSource = events

datEditEvents.DataBind()

ddlDeleteEvents.Items.Clear()

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

ddlDeleteEvents.Items.Add(New
ListItem(CDate(existevent("eventdate")).ToShortDat eString() & " " &
existevent("eventname"), existevent("eventid")))

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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uX**************@tk2msftngp13.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********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="update", and
a Button with CommandName="cancel". 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="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********@hotmail.com
http://www.nathansokalski.com/


Nov 19 '05 #4

P: n/a
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********@hotmail.com
http://www.nathansokalski.com/

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
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="update", and a Button with CommandName="cancel". 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="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.


Nov 19 '05 #5

P: n/a
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********@hotmail.com> wrote in message
news:O6*************@TK2MSFTNGP15.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
OracleConnection(System.Configuration.Configuratio nSettings.AppSettings("connectionString"))

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

Dim cmddelete As New OracleCommand("", myconnection)

Dim eventsadapter As New OracleDataAdapter(cmdselect)

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

eventsadapter.Fill(events, "eventlist")

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

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

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

myconnection.Open()

cmddelete.ExecuteNonQuery()

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

cmddelete.ExecuteNonQuery()

myconnection.Close()

If pastevent.Item("details") <> "" AndAlso
System.IO.File.Exists(Server.MapPath("eventdetails/" &
pastevent.Item("details"))) Then
System.IO.File.Delete(Server.MapPath("eventdetails/" &
pastevent.Item("details")))

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.CommandText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.SelectCommand = cmdselect

eventsadapter.Fill(events, "eventlist")

datEditEvents.DataSource = events

datEditEvents.DataBind()

ddlDeleteEvents.Items.Clear()

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

ddlDeleteEvents.Items.Add(New
ListItem(CDate(existevent("eventdate")).ToShortDat eString() & " " &
existevent("eventname"), existevent("eventid")))

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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uX**************@tk2msftngp13.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********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="update", and
a Button with CommandName="cancel". 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="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********@hotmail.com
http://www.nathansokalski.com/



Nov 19 '05 #6

P: n/a
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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uF**************@TK2MSFTNGP11.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********@hotmail.com> wrote in message
news:O6*************@TK2MSFTNGP15.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
OracleConnection(System.Configuration.Configuratio nSettings.AppSettings("connectionString"))

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

Dim cmddelete As New OracleCommand("", myconnection)

Dim eventsadapter As New OracleDataAdapter(cmdselect)

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

eventsadapter.Fill(events, "eventlist")

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

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

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

myconnection.Open()

cmddelete.ExecuteNonQuery()

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

cmddelete.ExecuteNonQuery()

myconnection.Close()

If pastevent.Item("details") <> "" AndAlso
System.IO.File.Exists(Server.MapPath("eventdetails/" &
pastevent.Item("details"))) Then
System.IO.File.Delete(Server.MapPath("eventdetails/" &
pastevent.Item("details")))

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.CommandText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.SelectCommand = cmdselect

eventsadapter.Fill(events, "eventlist")

datEditEvents.DataSource = events

datEditEvents.DataBind()

ddlDeleteEvents.Items.Clear()

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

ddlDeleteEvents.Items.Add(New
ListItem(CDate(existevent("eventdate")).ToShortDat eString() & " " &
existevent("eventname"), existevent("eventid")))

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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uX**************@tk2msftngp13.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********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I have a DataList control with an EditTemplate. Three of the controls in
this template include a Calendar, a Button with CommandName="update",
and a Button with CommandName="cancel". 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="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********@hotmail.com
http://www.nathansokalski.com/



Nov 19 '05 #7

P: n/a
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********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uF**************@TK2MSFTNGP11.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********@hotmail.com> wrote in message
news:O6*************@TK2MSFTNGP15.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
OracleConnection(System.Configuration.Configuratio nSettings.AppSettings("connectionString"))

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

Dim cmddelete As New OracleCommand("", myconnection)

Dim eventsadapter As New OracleDataAdapter(cmdselect)

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

eventsadapter.Fill(events, "eventlist")

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

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

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

myconnection.Open()

cmddelete.ExecuteNonQuery()

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

cmddelete.ExecuteNonQuery()

myconnection.Close()

If pastevent.Item("details") <> "" AndAlso
System.IO.File.Exists(Server.MapPath("eventdetails/" &
pastevent.Item("details"))) Then
System.IO.File.Delete(Server.MapPath("eventdetails/" &
pastevent.Item("details")))

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.CommandText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.SelectCommand = cmdselect

eventsadapter.Fill(events, "eventlist")

datEditEvents.DataSource = events

datEditEvents.DataBind()

ddlDeleteEvents.Items.Clear()

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

ddlDeleteEvents.Items.Add(New
ListItem(CDate(existevent("eventdate")).ToShortDat eString() & " " &
existevent("eventname"), existevent("eventid")))

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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uX**************@tk2msftngp13.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********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
>I have a DataList control with an EditTemplate. Three of the controls
>in this template include a Calendar, a Button with
>CommandName="update", and a Button with CommandName="cancel". 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="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********@hotmail.com
> http://www.nathansokalski.com/
>



Nov 19 '05 #8

P: n/a
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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:O0**************@TK2MSFTNGP10.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********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uF**************@TK2MSFTNGP11.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********@hotmail.com> wrote in message
news:O6*************@TK2MSFTNGP15.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
OracleConnection(System.Configuration.Configuratio nSettings.AppSettings("connectionString"))

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

Dim cmddelete As New OracleCommand("", myconnection)

Dim eventsadapter As New OracleDataAdapter(cmdselect)

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

eventsadapter.Fill(events, "eventlist")

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

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

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

myconnection.Open()

cmddelete.ExecuteNonQuery()

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

cmddelete.ExecuteNonQuery()

myconnection.Close()

If pastevent.Item("details") <> "" AndAlso
System.IO.File.Exists(Server.MapPath("eventdetails/" &
pastevent.Item("details"))) Then
System.IO.File.Delete(Server.MapPath("eventdetails/" &
pastevent.Item("details")))

Next

End If

'Fill DataSet with all remaining events

events.Clear()

cmdselect.CommandText = "SELECT * FROM eventlist ORDER BY eventdate"

eventsadapter.SelectCommand = cmdselect

eventsadapter.Fill(events, "eventlist")

datEditEvents.DataSource = events

datEditEvents.DataBind()

ddlDeleteEvents.Items.Clear()

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

ddlDeleteEvents.Items.Add(New
ListItem(CDate(existevent("eventdate")).ToShortDat eString() & " " &
existevent("eventname"), existevent("eventid")))

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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uX**************@tk2msftngp13.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********@hotmail.com> wrote in message
> news:%2***************@TK2MSFTNGP15.phx.gbl...
>>I have a DataList control with an EditTemplate. Three of the controls
>>in this template include a Calendar, a Button with
>>CommandName="update", and a Button with CommandName="cancel". 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="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********@hotmail.com
>> http://www.nathansokalski.com/
>>
>
>



Nov 19 '05 #9

P: n/a
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********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:O0**************@TK2MSFTNGP10.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********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uF**************@TK2MSFTNGP11.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********@hotmail.com> wrote in message
news:O6*************@TK2MSFTNGP15.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
> OracleConnection(System.Configuration.Configuratio nSettings.AppSettings("connectionString"))
>
> Dim cmdselect As New OracleCommand("SELECT * FROM eventlist WHERE
> eventdate<TO_DATE('" & Date.Now.ToShortDateString() &
> "','MM/DD/YYYY')", myconnection)
>
> Dim cmddelete As New OracleCommand("", myconnection)
>
> Dim eventsadapter As New OracleDataAdapter(cmdselect)
>
> 'Delete any past events and the people who registered for them
>
> eventsadapter.Fill(events, "eventlist")
>
> If events.Tables("eventlist").Rows.Count <> 0 Then
>
> For Each pastevent As DataRow In events.Tables("eventlist").Rows
>
> cmddelete.CommandText = "DELETE FROM registered WHERE eventid=" &
> pastevent.Item("eventid")
>
> myconnection.Open()
>
> cmddelete.ExecuteNonQuery()
>
> cmddelete.CommandText = "DELETE FROM eventlist WHERE eventid=" &
> pastevent.Item("eventid")
>
> cmddelete.ExecuteNonQuery()
>
> myconnection.Close()
>
> If pastevent.Item("details") <> "" AndAlso
> System.IO.File.Exists(Server.MapPath("eventdetails/" &
> pastevent.Item("details"))) Then
> System.IO.File.Delete(Server.MapPath("eventdetails/" &
> pastevent.Item("details")))
>
> Next
>
> End If
>
> 'Fill DataSet with all remaining events
>
> events.Clear()
>
> cmdselect.CommandText = "SELECT * FROM eventlist ORDER BY eventdate"
>
> eventsadapter.SelectCommand = cmdselect
>
> eventsadapter.Fill(events, "eventlist")
>
> datEditEvents.DataSource = events
>
> datEditEvents.DataBind()
>
> ddlDeleteEvents.Items.Clear()
>
> For Each existevent As DataRow In events.Tables("eventlist").Rows
>
> ddlDeleteEvents.Items.Add(New
> ListItem(CDate(existevent("eventdate")).ToShortDat eString() & " " &
> existevent("eventname"), existevent("eventid")))
>
> 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********@hotmail.com
> http://www.nathansokalski.com/
>
> "S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote
> in message news:uX**************@tk2msftngp13.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********@hotmail.com> wrote in message
>> news:%2***************@TK2MSFTNGP15.phx.gbl...
>>>I have a DataList control with an EditTemplate. Three of the controls
>>>in this template include a Calendar, a Button with
>>>CommandName="update", and a Button with CommandName="cancel".
>>>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="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********@hotmail.com
>>> http://www.nathansokalski.com/
>>>
>>
>>
>
>



Nov 19 '05 #10

P: n/a
I am running Windows XP Pro (and I do know how to use IIS on it), however, I
cannot set the project up on it for multiple reasons. First, the project
uses an Oracle DB which I do not have. Second, because it is a group project
as part of a temp job (it is not a personal site), it needs to be running on
the company's server and be available to my partner in the job (we are
students who got hired to continue a class project from the Spring 2005
semester). I have been looking really closely at my code, but because this
is my first time doing inline editing I am trying to get a little bit of
help from someone who has done it before.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:ur**************@TK2MSFTNGP12.phx.gbl...
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********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:O0**************@TK2MSFTNGP10.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********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.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********@hotmail.com
http://www.nathansokalski.com/

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:uF**************@TK2MSFTNGP11.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********@hotmail.com> wrote in message
> news:O6*************@TK2MSFTNGP15.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
>> OracleConnection(System.Configuration.Configuratio nSettings.AppSettings("connectionString"))
>>
>> Dim cmdselect As New OracleCommand("SELECT * FROM eventlist WHERE
>> eventdate<TO_DATE('" & Date.Now.ToShortDateString() &
>> "','MM/DD/YYYY')", myconnection)
>>
>> Dim cmddelete As New OracleCommand("", myconnection)
>>
>> Dim eventsadapter As New OracleDataAdapter(cmdselect)
>>
>> 'Delete any past events and the people who registered for them
>>
>> eventsadapter.Fill(events, "eventlist")
>>
>> If events.Tables("eventlist").Rows.Count <> 0 Then
>>
>> For Each pastevent As DataRow In events.Tables("eventlist").Rows
>>
>> cmddelete.CommandText = "DELETE FROM registered WHERE eventid=" &
>> pastevent.Item("eventid")
>>
>> myconnection.Open()
>>
>> cmddelete.ExecuteNonQuery()
>>
>> cmddelete.CommandText = "DELETE FROM eventlist WHERE eventid=" &
>> pastevent.Item("eventid")
>>
>> cmddelete.ExecuteNonQuery()
>>
>> myconnection.Close()
>>
>> If pastevent.Item("details") <> "" AndAlso
>> System.IO.File.Exists(Server.MapPath("eventdetails/" &
>> pastevent.Item("details"))) Then
>> System.IO.File.Delete(Server.MapPath("eventdetails/" &
>> pastevent.Item("details")))
>>
>> Next
>>
>> End If
>>
>> 'Fill DataSet with all remaining events
>>
>> events.Clear()
>>
>> cmdselect.CommandText = "SELECT * FROM eventlist ORDER BY eventdate"
>>
>> eventsadapter.SelectCommand = cmdselect
>>
>> eventsadapter.Fill(events, "eventlist")
>>
>> datEditEvents.DataSource = events
>>
>> datEditEvents.DataBind()
>>
>> ddlDeleteEvents.Items.Clear()
>>
>> For Each existevent As DataRow In events.Tables("eventlist").Rows
>>
>> ddlDeleteEvents.Items.Add(New
>> ListItem(CDate(existevent("eventdate")).ToShortDat eString() & " " &
>> existevent("eventname"), existevent("eventid")))
>>
>> 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********@hotmail.com
>> http://www.nathansokalski.com/
>>
>> "S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote
>> in message news:uX**************@tk2msftngp13.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********@hotmail.com> wrote in message
>>> news:%2***************@TK2MSFTNGP15.phx.gbl...
>>>>I have a DataList control with an EditTemplate. Three of the
>>>>controls in this template include a Calendar, a Button with
>>>>CommandName="update", and a Button with CommandName="cancel".
>>>>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="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********@hotmail.com
>>>> http://www.nathansokalski.com/
>>>>
>>>
>>>
>>
>>
>
>



Nov 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.