ASPX onleave in dropdownlist

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Hi,

Try to use onSelectedIndexChanged if you can.

Cheers,

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

Nic said:
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.
 
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.
 
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=en&lr=&ie=UTF-8&threadm=OIdIV4UYDHA
..1784%40TK2MSFTNGP09.phx.gbl&rnum=4&prev=/groups%3Fq%3Ddatabinding%2Btex
tbox%2Bnot%2Bupdating%2Bgroup:microsoft.public.dotnet.languages.csharp%2
6hl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dmicrosoft.public.dotnet.language
s.csharp%26selm%3DOIdIV4UYDHA.1784%2540TK2MSFTNGP09.phx.gbl%26rnum%3D4
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top