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

ASPX onleave in dropdownlist

P: n/a
Nic
Hey,

I have an ASP-application. In the ASPX I have an <asp:dropdownlist ..>.
Now when I leave this control I want to initialisize some other fields. In window forms we uses the onleave event but here it don't exists.
How can I resolve this problem?

Tkx;
Nic
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

Try to use onSelectedIndexChanged if you can.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Nic" <Ni*@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
Hey,

I have an ASP-application. In the ASPX I have an <asp:dropdownlist ..>.
Now when I leave this control I want to initialisize some other fields. In window forms we uses the onleave event but here it don't exists. How can I resolve this problem?

Tkx;
Nic

Nov 16 '05 #2

P: n/a
Hi Nic:

This sort of functionality can be added with some client side script.
There is an OnBlur event you can catch:

DropDownList1.Attributes["OnBlur"] =
"javascript:alert('OnBlur fired');";

People in the aspnet newsgroup could give you more examples and
detail.

--
Scott
http://www.OdeToCode.com

On Tue, 13 Jul 2004 04:53:04 -0700, Nic
<Ni*@discussions.microsoft.com> wrote:
Hey,

I have an ASP-application. In the ASPX I have an <asp:dropdownlist ..>.
Now when I leave this control I want to initialisize some other fields. In window forms we uses the onleave event but here it don't exists.
How can I resolve this problem?

Tkx;
Nic


Nov 16 '05 #3

P: n/a
Hi all

Having nightmares with data binding, been searching the archives and
come up with a couple of posts

Firstly this exactly describes my problem
This is a /very/ odd problem and any insight would be greatly appreciated.
1) I have used SqlDataAdapter to fill a DataTable in a DataSet.
2) I binded textbox's "Text" property to columns in the DataTable.
3) I edit the textboxes Text value.
in doing so, the DataTable's values have changed
I know this because i have done:
MessageBox.Show(dataTable.Rows[0]["colname"].ToString());
4) I attempt to update the database: myDataAdapter.Update(myDataSet, "tablename");
this does not work.

now the weird part:

if you replace steps 2 and 3 with:
2) Create a datagrid whose DataSource = myDataSet.Tables["tablename"]; 3) make changes in the datagrid

then step will 4 work correctly. (somehow the datagrid must change the dataset differently than the textboxes do, it appears)
however, this makes no sense, because doing:
MessageBox.Show(dataTable.Rows[0]["colname"].ToString());
prints the same thing with both methods

what is /really/ weird:

Suppose I have both the textboxes and the datagrid, both bound to the DataTable. When I edit a textbox, then try and update the database, it sitll doesn't work (as expected, because it didn't work before). However, If I edit a textbox, then merely click on the datagrid (give it focus) the value in the datagrid then changes (as if its being refreshed to show the change I made to the textbox). now, after clicking the datagrid, when I press try and update the database: myDataAdapter.Update(myDataSet,
"tablename"); it WORKS.

I have have absolutely no idea why merely clicking on the datagrid makes a difference. They are both bound to the same DataSet/DataTable.

This appears to be the solution (Below), which I am just about to try
However my basic question is.. Is the correct approach ???
My understanding (perhaps misunderstanding) was such that the point of
databinding was to save coding these types of things, I guess not the
case or is this not the appraoch to take..

Many thanks in advance
Dave

I have solved the problem.

the problem was, for a datarow that you're editing, before you edit it you have to call BeginEdit(), then when all the changes are done, before you Update() (stick the datatable back in the database) you have to call
EndEdit(). After you update, call AcceptChanges(), which changes tells the datatable it is synch'd with the database, sorta.

The reason a datagrid was working and not the textbox, i suspect, is because the datagrid internally takes care of the BeginEdit()/EndEdit() things.
Hope this helps, if not, write back

Link Reference :
http://groups.google.co.uk/groups?hl...dm=OIdIV4UYDHA
..1784%40TK2MSFTNGP09.phx.gbl&rnum=4&prev=/groups%3Fq%3Ddatabinding%2Btex
tbox%2Bnot%2Bupdating%2Bgroup:microsoft.public.dot net.languages.csharp%2
6hl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dmicrosoft.public.dotnet.language
s.csharp%26selm%3DOIdIV4UYDHA.1784%2540TK2MSFTNGP0 9.phx.gbl%26rnum%3D4

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.