making a dropdownlist visible when clicking in a textbox of a detailsview?


A

André

Hi,

I made a detailsview containing several fields for inserting only. I also
made a dropdownlist which is invisible at start.
Now, when clicking in a particular textbox, the dropdownlist must become
visible (in order to put the selected value of the dropdownlist into the
textbox of the detailsgrid.). I must say, the detailsview contains
textboxes, but also a checkbox.

I tried a lot of things, but i don't know which events to take:
<asp:DetailsView ID="DetailsView1" runat="server"
DataSourceID="SqlDataSource1
.....
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource2"
.....
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
....
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
.....


In the code-behind, i tried thinks like:
Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound
Dim a As DataControlField
a = DetailsView1.Fields(5)

if ??? then
dropdownlist1.visible=True
end if

End Sub

or
Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles
DetailsView1.ItemInserting
Dim a As New TextBox
a = DetailsView1.Rows(2)
if ??? then
dropdownlist1.visible=True
end if
End Sub

Can somebody tell me which event to take and how to check if the mouse is
clicked in the right textbox?
Thanks
André
 
Ad

Advertisements

B

bruce barker \(sqlwork.com\)

you must use client code for this (posting back on textbox focus so that
server side code coudl do it is not a good idea). this means you must render
the dropdown. use style commands to hide, not the visible property. then in
client onclick, change the style. pick up any book on javascript.

-- bruce (sqlwork.com)
 
Ad

Advertisements

A

André

Ok thanks

bruce barker (sqlwork.com) said:
you must use client code for this (posting back on textbox focus so that
server side code coudl do it is not a good idea). this means you must render
the dropdown. use style commands to hide, not the visible property. then in
client onclick, change the style. pick up any book on javascript.

-- bruce (sqlwork.com)
 

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

Top