Hi folks,
I need to have two ddl's in one DataGrid cell. The first ddl has a list of
company names and the second has a list of contact names that work in the
company name that was selected in the first ddl.
Any replies will be greatly appreciate.
Here are 3 functions / subroutines that do the following:
1) GetCompanyNames ForThisProject
2) GetContactsFrom CompanyForThisP roject
3) ddlTo_SelectedI ndexChanged
Function GetCompanyNames ForThisProject( ) as DataSet
dsCompanyNames. Clear()
Dim strConnString As String = "Provider=Micro soft.Jet.OLEDB. 4.0;
Ole DB Services=-4; Data
Source=c:\sites \single29\gmead ows73\database\ fdmdb.mdb"
Dim queryString As String = "SELECT DISTINCT [users].[cname] FROM
[users] WHERE ([users].[project] = '" & Session("projec t") & "')"
Dim dataAdapter As New OleDbDataAdapte r (querystring, strConnString)
dataAdapter.Fil l(dsCompanyName s, "users
Return dsCompanyNames
End Function
Function GetContactsFrom CompanyForThisP roject () As DataSet
' dsContacts.Clea r()
Dim strConnString As String =
"Provider=Micro soft.Jet.OLEDB. 4.0; Ole DB Services=-4; Data
Source=C:\sites \single29\gmead ows73\database\ fdmdb.mdb"
Dim queryString As String
queryString = "SELECT [users].[name] FROM [users] WHERE
(([users].[cname] = '" & coName & "') AND ([users].[project] = '" &
Session("projec t") & "'))"
Dim dataAdapter As New OleDbDataAdapte r (queryString,
strConnString)
dataAdapter.Fil l(dsContacts, "users")
Return dsContacts
End Function
Sub ddlTo_SelectedI ndexChanged(sen der As Object, e As EventArgs)
Dim list As DropDownList = CType(sender, DropDownList)
coName = list.SelectedIt em.Text
Dim ddlContact As DropDownList = CType(sender, DropDownList)
ddlContact.Data Source = GetContactsFrom CompanyForThisP roject ()
ddlContact.Data Bind ( )
End Sub
The first ddl is populated with company names. When it is selected the code
travels into the second function to get the contact names for the company
that was selected. The problem is that the second ddl is never populated
with the contact names.
My DataGrid html snippet is as follows:
<asp:TemplateCo lumn HeaderText="To"
SortExpression= "questionto ">
<ItemTemplate >
<%# DataBinder.Eval (Container.Data Item,
"questionto ") %>
</ItemTemplate>
<EditItemTempla te>
<asp:Label id="lblFrom" text="Company: "
runat="server" />
<br />
<asp:DropDownLi st id="ddlTo" runat="server"
DataValueField= "cname" AutoPostBack="T rue" DataSource='<%#
GetCompanyNames ForThisProject( ) %>'
OnSelectedIndex Changed="ddlTo_ SelectedIndexCh anged" />
<asp:Label id="lblContact " text="Contact: "
runat="server" />
<br />
<asp:DropDownLi st id="ddlContact " runat="server"
DataValueField= "name" AutoPostBack="T rue" DataSource='<%#
GetContactsFrom CompanyForThisP roject() %>'/>
</EditItemTemplat e>
</asp:TemplateCol umn> 1 1326
Hi folks,
Solved my own problem. For anyone interested, the following snippet needs
to go inside of your OnSelectItem subroutine:
Dim list As DropDownList = CType(sender, DropDownList)
coName = list.SelectedIt em.Text
Dim cell As TableCell = CType(list.Pare nt, TableCell)
Dim item As DataGridItem = CType(cell.Pare nt, DataGridItem)
Dim ddlContact As DropDownList =
CType(item.Find Control("ddlCon tact"), DropDownList)
ddlContact.Data Source = GetContactsFrom CompanyForThisP roject ()
ddlContact.Data Bind ( )
"glenn" wrote: Hi folks,
I need to have two ddl's in one DataGrid cell. The first ddl has a list of company names and the second has a list of contact names that work in the company name that was selected in the first ddl.
Any replies will be greatly appreciate.
Here are 3 functions / subroutines that do the following:
1) GetCompanyNames ForThisProject 2) GetContactsFrom CompanyForThisP roject 3) ddlTo_SelectedI ndexChanged
Function GetCompanyNames ForThisProject( ) as DataSet dsCompanyNames. Clear() Dim strConnString As String = "Provider=Micro soft.Jet.OLEDB. 4.0; Ole DB Services=-4; Data Source=c:\sites \single29\gmead ows73\database\ fdmdb.mdb" Dim queryString As String = "SELECT DISTINCT [users].[cname] FROM [users] WHERE ([users].[project] = '" & Session("projec t") & "')"
Dim dataAdapter As New OleDbDataAdapte r (querystring, strConnString)
dataAdapter.Fil l(dsCompanyName s, "users
Return dsCompanyNames End Function
Function GetContactsFrom CompanyForThisP roject () As DataSet ' dsContacts.Clea r() Dim strConnString As String = "Provider=Micro soft.Jet.OLEDB. 4.0; Ole DB Services=-4; Data Source=C:\sites \single29\gmead ows73\database\ fdmdb.mdb"
Dim queryString As String queryString = "SELECT [users].[name] FROM [users] WHERE (([users].[cname] = '" & coName & "') AND ([users].[project] = '" & Session("projec t") & "'))"
Dim dataAdapter As New OleDbDataAdapte r (queryString, strConnString)
dataAdapter.Fil l(dsContacts, "users")
Return dsContacts End Function
Sub ddlTo_SelectedI ndexChanged(sen der As Object, e As EventArgs) Dim list As DropDownList = CType(sender, DropDownList) coName = list.SelectedIt em.Text
Dim ddlContact As DropDownList = CType(sender, DropDownList) ddlContact.Data Source = GetContactsFrom CompanyForThisP roject () ddlContact.Data Bind ( ) End Sub
The first ddl is populated with company names. When it is selected the code travels into the second function to get the contact names for the company that was selected. The problem is that the second ddl is never populated with the contact names.
My DataGrid html snippet is as follows:
<asp:TemplateCo lumn HeaderText="To" SortExpression= "questionto "> <ItemTemplate > <%# DataBinder.Eval (Container.Data Item, "questionto ") %> </ItemTemplate> <EditItemTempla te> <asp:Label id="lblFrom" text="Company: " runat="server" /> <br /> <asp:DropDownLi st id="ddlTo" runat="server" DataValueField= "cname" AutoPostBack="T rue" DataSource='<%# GetCompanyNames ForThisProject( ) %>' OnSelectedIndex Changed="ddlTo_ SelectedIndexCh anged" /> <asp:Label id="lblContact " text="Contact: " runat="server" /> <br /> <asp:DropDownLi st id="ddlContact " runat="server" DataValueField= "name" AutoPostBack="T rue" DataSource='<%# GetContactsFrom CompanyForThisP roject() %>'/> </EditItemTemplat e> </asp:TemplateCol umn> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DotNetJunkies User |
last post by:
Hie,
I create a dynamique HtmlTable, in each cell of this HtmlTable put a new control ( dropdownlist,label,..) and then want to create handler so that if i change the select item in the dop downlist i change the text displayed in the label in the same row.
hier is my code:
using System;
using System.Collections;
using System.ComponentModel;...
|
by: Sid |
last post by:
Hi All,
I am trying to populate a dropdown list in my Datagrid
control using the OleDbDataReader, but when my function
tries to add items to the dropdownlist it says that my
dropdownlist control has not been 'declared' even though
it is set to runat="server" .
Any ideas?
|
by: Julia Hu |
last post by:
Hi,
I have a datagrid, and in different rows I need to
programmatically bind different type of controls and load
data into these controls. For example,in the first row I
need to bind data into a textbox, and in the second row I
need to bind data into a dropdownlist...It all depends on
the data I select from the database.
I cannot use...
|
by: Luis Esteban Valencia |
last post by:
Hello. I have a datagrid with one row. I have a button that adds a new row.
I am trying to implement that when the user selects one product it must
change the price on the quantity column. Anyway when the user selects the
first dropdownlist the dropdownselected_indexchanged is firring but when the
user chagnes the second dropdownlist its not...
|
by: Daniel Doyle |
last post by:
Hello and apologies in advance for the amount of code in this post. I've
also sent this message to the Sharepoint group, but thought that ASP.NET
developers may also be able to help, even though it's a Sharepoint WebPart.
I'm trying to do something fairly simple, create a datagrid that displays
where
and when a person works and allows them to...
| |
by: jimb |
last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I
can't read it.
Anybody have a working example of a dropdownlist in an editable grid?
Thanks.
--
..
http://sf-f.org, weblog and search engine for fans and writers of
|
by: Frank |
last post by:
Hello,
I am developing with VS.Net 2003 on the asp 1.1 platform.
I am a few days new to using a datagrid. I found a nice tutorial and had no
problems using an editable datagrid with textboxes and an additional
buttoncolumn where I used a delete button to delete a specific row.
Once I had finished that, I trnsformed the grid tso it will...
|
by: glenn |
last post by:
Hi folks,
I have a DropDownList in a DataGrid that is populated from records in a
database.
I want to add a value that might be a string such as "Select a Company" for
the first item since an OnSelectedIndex event is not fired if you select the
first item.
Does anyone know of an easy way to do this?
|
by: Arpan |
last post by:
Consider the following code which retrieves data from a SQL Server 2005
DB table & displays it in a DataGrid:
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim dSet As DataSet
Dim sqlConn As SqlConnection
Dim sqlDapter As SqlDataAdapter
sqlConn = New SqlConnection("Data Source=AD\SQLEXPRESS;Initial
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |