EditTemplate内的控件导致编辑结束 [英] Controls inside EditTemplate cause editing to end

查看:50
本文介绍了EditTemplate内的控件导致编辑结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有EditTemplate的DataList控件。这个模板中的三个控件包括一个日历,一个CommandName =update的按钮,以及一个带有CommandName =cancel的

按钮。每当我单击其中一个控件时,

DataList会将EditTemplate替换为ItemTemplate。我认为这是

是因为我编写的执行数据绑定的方法是调用

,但我不知道为什么或从哪里调用它。它没有从我的Page_Load方法调用
而且我没有ItemCommand事件

处理程序,所以我不知道从哪里开始测试它。当我单击按钮时,我测试了是否

我的UpdateCommand事件被调用了

CommandName =" update"通过为Label控件分配一些文本,所以我知道

它永远不会被调用。什么可能导致我的问题?任何帮助

将不胜感激。谢谢。

-

Nathan Sokalski
nj * *******@hotmail.com
http:// www.nathansokalski.com/

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/

推荐答案

Nathan,


确保您的DataList控件将它的viewstate属性设置为

true然后,无论你在代码中绑定DataList,将

代码包装在:


如果不是IsPostBack然后

''---在这里绑定你的数据列表。

结束如果


我不知道你在做数据绑定的确切位置,但是从你所描述的内容来看,我认为你已经正确识别了你的问题。你的数据列表

正在重新绑定回发。


顺便说一句,请不要一次发布到多个新闻组。 。

-

此致,


S. Justin Gengo,MCP

Web开发人员/程序员

www.aboutfortunate.com


混乱无序。

Nietzsche

" Nathan Sokalski" < NJ ******** @ hotmail.com>在消息中写道

新闻:%2 *************** @ TK2MSFTNGP15.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...
我有一个使用EditTemplate进行DataList控件。这个模板中的三个控件包括一个Calendar,一个CommandName =update的按钮,以及一个CommandName =" cancel"的按钮。每当我单击其中一个控件时,DataList就会用EditTemplate替换EditTemplate。我认为这是因为我编写的执行数据绑定的方法是调用
,但我不知道为什么或从哪里调用它。它没有从我的Page_Load方法调用,我没有ItemCommand
事件处理程序,所以我不知道从哪里开始测试它。我测试了当我点击按钮
并使用CommandName =" update"时,看看我的UpdateCommand事件是否被调用通过为Label控件分配一些文本,我知道它永远不会被调用。什么可能导致我的问题?任何
帮助将不胜感激。谢谢。
-
Nathan Sokalski
nj ******** @ hotmail.com
http://www.nathansokalski.com/
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/



它是从Button的OnCommand事件处理程序调用的。通过部件控件层次结构,OnCommand被冒泡

所以像按钮这样的子控件可以

将命令发送到父控件。


-Brock

DevelopMentor
http:// staff .develop.com / ballen
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
我有一个带有EditTemplate的DataList控件。此模板中的三个控件包括一个日历,一个带有CommandName =" update"的按钮,以及一个带有CommandName =" cancel"的按钮。每当我点击其中一个控件时,DataList就会用EditTemplate替换EditTemplate
。我认为这是因为我编写的执行数据绑定的方法被调用,但我不知道为什么
或它从哪里调用。它没有从我的
Page_Load方法调用,我没有ItemCommand事件处理程序,所以我不知道从哪里开始测试它。我测试了当我点击按钮时,我的
UpdateCommand事件是否被调用
CommandName =" update"通过为Label控件分配一些文本,我知道它永远不会被调用。什么可能导致我的
问题?任何帮助,将不胜感激。谢谢。
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.






我的DataList'的EnableViewState属性设置为True。我已经尝试将我的绑定代码包装在一个If Not IsPostBack Then语句中,就像你说的那样,但

导致绑定不会在其他时候发生,而它确实需要

发生。我有一个方法,包含我在我的

Page_Init方法中调用的绑定代码,以及在对数据库进行任何更改后,我使用

作为我的数据源。此方法如下:


Private Sub RefreshEvents()


将事件视为新数据集


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作为新的OracleDataAdapter(cmdselect)


''删除任何过去的事件和注册的人


eventsadapter.Fill(事件,& ; eventlist")


如果events.Tables(" eventlist")。Rows.Count<> 0然后


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


cmddelete.CommandText =" DELETE FROM注册WHERE eventid =" &

pastevent.Item(" eventid")

myconnection.Open()


cmddelete。 ExecuteNonQuery()


cmddelete.CommandText =" DELETE FROM eventlist WHERE eventid =" &

pastevent.Item(" eventid")

cmddelete.ExecuteNonQuery()


myconnection。关闭()


如果是pastevent.Item(" details")<> ""并且还要

System.IO.File.Exists(Server.MapPath(" eventdetails /"&

pastevent.Item(" details")))然后

System.IO.File.Delete(Server.MapPath(" eventdetails /"&

pastevent.Item(" details")))


下一页


结束如果


''将所有剩余事件填入DataSet

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)。行


ddlDeleteEvents.Items.Add(新

ListItem(CDate(existevent(" eventdate"))。ToShortDat eStr ing()& " " &

existevent(" eventname"),existevent(" eventid")))


下一页


End Sub

还有其他想法吗?如果你想看到我使用的任何其他代码,只需

让我知道。谢谢。

-

Nathan Sokalski
nj * *******@hotmail.com
http:// www.nathansokalski.com/


" S. Justin Gengo < sjgengo @ [no_spam_please] aboutfortunate.com>写在

消息新闻:uX ************** @ tk2msftngp13.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, true然后,无论您在代码中绑定DataList,请将该代码包装在:

如果不是IsPostBack那么
''---在这里绑定你的数据列表。
结束如果

我不知道你在做数据绑定的确切位置,但从您描述的内容我认为您已正确识别您的问题。你的数据列表正在回发中重新绑定。

顺便说一下,请不要一次发布到多个新闻组...

-
真诚的,

S. Justin Gengo,MCP
Web开发人员/程序员

www.aboutfortunate.com

出于混乱而来的订单。
Nietzsche Nathan Sokalski < NJ ******** @ hotmail.com>在消息中写道
新闻:%2 *************** @ TK2MSFTNGP15.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...
我有一个DataList控件EditTemplate。这个模板中的三个控件包括一个Calendar,一个CommandName =update的按钮,以及一个CommandName =" cancel"的按钮。每当我单击其中一个
控件时,DataList就会用EditTemplate替换EditTemplate。我认为这是因为我编写的执行数据绑定的方法被调用,但我不知道为什么或从哪里调用它。
它没有被调用从我的Page_Load方法,我没有一个
ItemCommand事件处理程序,所以我不知道从哪里开始测试它。
我测试了当我点击时我的UpdateCommand事件是否被调用
具有CommandName =" update"的按钮通过为Label
控件分配一些文本,所以我知道它永远不会被调用。什么可能导致我的问题?任何帮助,将不胜感激。谢谢。
-
Nathan Sokalski
nj ******** @ hotmail.com
http://www.nathansokalski.com/
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/




这篇关于EditTemplate内的控件导致编辑结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆