Monday, March 26, 2012
populate ddl from two tables
I have two Tables: Table1: GroupID1, GroupName1 and Table2:GroupID2,
GroupName2.
I have only one dropdown list (DropDownList1) in my application and through
a stored procedure I want to populate my DropDownList1 from GroupName1 and
GroupName2. How should I write my query?
Thanks,
Jim.You'll probably want to use a union.
select companyname from suppliers union select shipcity from orders
try this on Northwind, it'll return the companynames and shipcity in one
long list.
HTH
Pete
--
http://www.xboxracing.net/
"JIM.H." wrote:
> Hello,
> I have two Tables: Table1: GroupID1, GroupName1 and Table2:GroupID2,
> GroupName2.
> I have only one dropdown list (DropDownList1) in my application and throug
h
> a stored procedure I want to populate my DropDownList1 from GroupName1 and
> GroupName2. How should I write my query?
> Thanks,
> Jim.
>
Jim,
You need to join 2 tables with a UNION query.
Eliyahu
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:318E29E9-6546-43E0-9B65-C0529E58FA96@.microsoft.com...
> Hello,
> I have two Tables: Table1: GroupID1, GroupName1 and Table2:GroupID2,
> GroupName2.
> I have only one dropdown list (DropDownList1) in my application and
through
> a stored procedure I want to populate my DropDownList1 from GroupName1 and
> GroupName2. How should I write my query?
> Thanks,
> Jim.
>
Can you give me an example?
"Eliyahu Goldin" wrote:
> Jim,
> You need to join 2 tables with a UNION query.
> Eliyahu
> "JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
> news:318E29E9-6546-43E0-9B65-C0529E58FA96@.microsoft.com...
> through
>
>
populate ddl from two tables
I have two Tables: Table1: GroupID1, GroupName1 and Table2:GroupID2,
GroupName2.
I have only one dropdown list (DropDownList1) in my application and through
a stored procedure I want to populate my DropDownList1 from GroupName1 and
GroupName2. How should I write my query?
Thanks,
Jim.You'll probably want to use a union.
select companyname from suppliers union select shipcity from orders
try this on Northwind, it'll return the companynames and shipcity in one
long list.
HTH
Pete
--
http://www.xboxracing.net/
"JIM.H." wrote:
> Hello,
> I have two Tables: Table1: GroupID1, GroupName1 and Table2:GroupID2,
> GroupName2.
> I have only one dropdown list (DropDownList1) in my application and through
> a stored procedure I want to populate my DropDownList1 from GroupName1 and
> GroupName2. How should I write my query?
> Thanks,
> Jim.
Jim,
You need to join 2 tables with a UNION query.
Eliyahu
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:318E29E9-6546-43E0-9B65-C0529E58FA96@.microsoft.com...
> Hello,
> I have two Tables: Table1: GroupID1, GroupName1 and Table2:GroupID2,
> GroupName2.
> I have only one dropdown list (DropDownList1) in my application and
through
> a stored procedure I want to populate my DropDownList1 from GroupName1 and
> GroupName2. How should I write my query?
> Thanks,
> Jim.
Can you give me an example?
"Eliyahu Goldin" wrote:
> Jim,
> You need to join 2 tables with a UNION query.
> Eliyahu
> "JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
> news:318E29E9-6546-43E0-9B65-C0529E58FA96@.microsoft.com...
> > Hello,
> > I have two Tables: Table1: GroupID1, GroupName1 and Table2:GroupID2,
> > GroupName2.
> > I have only one dropdown list (DropDownList1) in my application and
> through
> > a stored procedure I want to populate my DropDownList1 from GroupName1 and
> > GroupName2. How should I write my query?
> > Thanks,
> > Jim.
>
Wednesday, March 21, 2012
Populating a DataGrid with a Stored Procedure based on ddl values
Hello All -
First off, I am a complete newbie.
I have created a page with 5 dropdownlists that I populated using stored procedures.
Question one:
How Do I display a default value for these Dropdowns?
I have configured a DataGrid using another Stored Procedure.
Question 2:
How Do I populate the DG with the values specified within the 5 dropdownlists using a stored procedure?
Here is a copy of the current aspx page.
<%@dotnet.itags.org.PageLanguage="VB"MasterPageFile="~/MasterPage.master"Title="CTM PreRunbook" %>
<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><table><tr><thalign="center"colspan="3"style="vertical-align: middle; text-align: center"valign="middle">
<asp:LabelID="Label1"runat="server"Font-Size="Large"Text="Data Feed Query"></asp:Label> </th></tr><tr>
<th>
Application Name:</th>
<tdalign="right"style="vertical-align: top; text-align: left">
<tdstyle="width: 31px">
<asp:DropDownListID="ddlAppName"runat="server"AutoPostBack="True"DataSourceID="SqlDataSource1"DataTextField="AppName"DataValueField="AppName">
<asp:ListItem>- Select -</asp:ListItem>
</asp:DropDownList><asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:PreRunbookConnectionString %>"
SelectCommand="spGet_AppName"SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</td></tr><tr>
<th>
Data Feed Name:</th>
<tdalign="right"style="vertical-align: top; text-align: left">
<tdstyle="width: 31px; text-align: left;">
<asp:DropDownListID="ddlDataFeedName"runat="server"AutoPostBack="True"DataSourceID="SqlDataSourceDependantFeeds"DataTextField="FeedName"DataValueField="FeedName">
</asp:DropDownList><asp:SqlDataSourceID="SqlDataSourceDependantFeeds"runat="server"
ConnectionString="<%$ ConnectionStrings:PreRunbookConnectionString %>"SelectCommand="spGet_FeedNames"
SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</td></tr>
<tr>
<th>
Account:</th>
<tdalign="right"style="vertical-align: top; text-align: left">
<tdstyle="width: 31px">
<asp:DropDownListID="ddlAccount"runat="server"AutoPostBack="True"DataSourceID="SqlDataSourceServiceAccount"DataTextField="ServiceAccounts"DataValueField="ServiceAccounts">
</asp:DropDownList><asp:SqlDataSourceID="SqlDataSourceServiceAccount"runat="server"
ConnectionString="<%$ ConnectionStrings:PreRunbookConnectionString %>"SelectCommand="spGetDistinctServiceAccounts"
SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</td></tr><tr>
<th>
Platform:</th>
<tdalign="right"style="vertical-align: top; text-align: left">
<tdstyle="width: 31px; text-align: left;">
<asp:DropDownListID="ddlPlatform"runat="server"AutoPostBack="True"DataSourceID="SqlDataSourcePlatform"DataTextField="Platform"DataValueField="Platform">
</asp:DropDownList><asp:SqlDataSourceID="SqlDataSourcePlatform"runat="server"ConnectionString="<%$ ConnectionStrings:PreRunbookConnectionString %>"
SelectCommand="spGet_Platform"SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</td></tr><tr>
<th>
Scheduled Run Days:</th>
<tdalign="right"style="vertical-align: top; text-align: left">
<tdstyle="width: 31px">
<asp:DropDownListID="ddlSchedRunDays"runat="server"AutoPostBack="True"DataSourceID="SqlDataSourceSchedRunDays"DataTextField="ScheduledRunDays"DataValueField="ScheduledRunDays">
</asp:DropDownList><asp:SqlDataSourceID="SqlDataSourceSchedRunDays"runat="server"
ConnectionString="<%$ ConnectionStrings:PreRunbookConnectionString %>"SelectCommand="spGet_ScheduledRunDays"
SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</td></tr>
</Table>
<table>
<tr>
<tdstyle="width: 100px"align="center">
<asp:ButtonID="btnFilter"runat="server"Text="Filter"/></td>
<tdstyle="width: 100px">
<asp:ButtonID="btnReset"runat="server"Text="Reset"/></td>
</tr>
<tr>
<tdcolspan="2"align="center">
<asp:ButtonID="btnShowAllDataFeeds"runat="server"Text="Show All Data Feeds"/></td>
</tr>
</table>
<br/>
<asp:GridViewID="GridView1"runat="server"AllowPaging="True"AllowSorting="True"
AutoGenerateColumns="False"DataSourceID="SqlDataSourceGridView">
</asp:GridView>
<asp:SqlDataSourceID="SqlDataSourceGridView"runat="server"ConnectionString="<%$ ConnectionStrings:PreRunbookConnectionString %>"
SelectCommand="spFilterByServAcct"SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:FormParameterFormField="ServiceAccounts"Name="ServAcct"
Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
<br>
</asp:Content>
Thanks ,
Pat
here is the best example that describes your needs
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/sqldatasource.aspx
Populating a DDL with users from Active Directory
in active directory. I don't even know where to begin, really.
I added a reference to System.DirectoryServices so I could use the
System.DirectoryServices.ActiveDirectory namespace. I don't even know if
this is the right way to go as I can't seem to find anything in that
namespace that would help me query active directory for names.
I can't use an LDAP query because lDAP isn't working on our network for
some reason (never has. i posted a note asking help for this on the
win2000.general newsgroup but no one replied).
So, even if I could use the framework to access active directory to get
a list of all the users, what about security? I don't think the aspnet
account on the web server has access to the domain's directory. How
would I go about specifying an account that could be used to access the
directory (if its necessary to do so)?
All this would need to be done in VB as I don't know C#. Oh, and I'm
using VS 2005 and .NET 2.0.
Thanks!
Jim>My goal, somehow, is to populate a dropdownlist with all the user names
Quote:
Originally Posted by
>in active directory. I don't even know where to begin, really.
OK, the very FIRST question I would ask myself is : REALLY ?? Do you
really need this, and second, if yes - how many users will you be
displaying?? If you have a dozen or two - okay, no problem.
If you have more than 50 or so - forget it - won't work. Having huge
long lists of user name is just totally against all usability.
Quote:
Originally Posted by
>I added a reference to System.DirectoryServices so I could use the
>System.DirectoryServices.ActiveDirectory namespace. I don't even know if
>this is the right way to go as I can't seem to find anything in that
>namespace that would help me query active directory for names.
Sure, you're on the right track. Next thing you need to do is this:
since you have a domain with any number of potential organizational
units (OU's) inside it structuring your organization, you will need to
do a domain-wide search for users (if you really want that).
Again: an alternative might be to do a two-stage search. First present
the user with a list of all OU's in your domain (usually a couple or a
few dozen), e.g. "Finance", "R&D" and so forth. Once the user has
picked the OU he wants to see, then search the users inside that
(usually a MUCH smaller number than ALL the domain users) and shows
just those in a second dropdown.
Quote:
Originally Posted by
>I can't use an LDAP query because lDAP isn't working on our network for
>some reason (never has. i posted a note asking help for this on the
>win2000.general newsgroup but no one replied).
Well, if you can't use LDAP, you're totally out of luck. Active
Directory and all the System.DirectoryServices stuff is based on LDAP.
No LDAP, no go......
So, once you've decided what to do and LDAP is working, here's how you
can do a domain-wide search - if you really want to do it in the end.
First you need to know what your domain is - either ask your domain
admin, or you can peek it like so (sorry, I'm fluent in C# only, so
you'll have to do the translations to VB.NET yourself or use one of
the C#-to-VB.NET translators out there on the 'net):
// bind to the LDAP root
DirectoryEntry root = new DirectoryEntry("LDAP://RootDSE");
// grab the defaultNamingContext
string myDomain = root.Properties["defaultNamingContext"].Value;
Next, once you have your domain name, you need to set up a domain
searcher on the domain level, and search for all users inside it:
DirectoryEntry domain = new DirectoryEntry("LDAP://" + myDomain);
DirectorySearcher dsUsers = new DirectorySearcher(domain);
// set up the searcher properties - search users, and return
// just their distinguishedName, givenName (first name), and
// sn (surname = family name)
dsUsers.Filter = "(&(objectCategory=person)(objectClass=user))";
dsUsers.PropertiesToLoad.Add("distinguishedName");
dsUsers.PropertiesToLoad.Add("givenName");
dsUsers.PropertiesToLoad.Add("sn");
Now let the searcher do its magic and find all users - you will get a
"SearchResult" object back, in which you can access all the properties
you've specified in the "PropertiesToLoad" collection:
List<stringallDomainUsers = new List<string>();
foreach(SearchResult result in dsUsers.FindAll() )
{
// grab the properties and store them somewhere, e.g. in a
// List<stringor something like that, which can then be
// bound to a combobox
string firstName = result.Properties["givenName"][0].ToString();
string lastName = result.Properties["sn"][0].ToString();
allDomainUsers.Add(firstName + " " + lastName);
}
Hope this helps you get started a bit.
If you have more questions, you can go to the MSDN
System.DirectoryServices portal here:
http://msdn.microsoft.com/library/d.../sds/portal.asp
There are LOTS of really good examples there, in both C# and VB.NET.
Or buy the excellent book by my fellow MVP's Joe Kaplan and Ryan Dunn
- really excellent stuff about Active Directory programming!
The .NET Developer's Guide to Directory Services Programming
(Microsoft Net Development Series)
http://www.amazon.com/gp/product/0321350170/
Or post here again, of course - better yet - post in the
microsoft.public.adsi.general group, that's the hard-core Active
Directory programming group.
Marc
Marc Scheuner wrote:
Quote:
Originally Posted by
Quote:
Originally Posted by
>My goal, somehow, is to populate a dropdownlist with all the user names
>in active directory. I don't even know where to begin, really.
>
OK, the very FIRST question I would ask myself is : REALLY ?? Do you
really need this, and second, if yes - how many users will you be
displaying?? If you have a dozen or two - okay, no problem.
>
If you have more than 50 or so - forget it - won't work. Having huge
long lists of user name is just totally against all usability.
>
Quote:
Originally Posted by
>I added a reference to System.DirectoryServices so I could use the
>System.DirectoryServices.ActiveDirectory namespace. I don't even know if
>this is the right way to go as I can't seem to find anything in that
>namespace that would help me query active directory for names.
>
Sure, you're on the right track. Next thing you need to do is this:
since you have a domain with any number of potential organizational
units (OU's) inside it structuring your organization, you will need to
do a domain-wide search for users (if you really want that).
>
Again: an alternative might be to do a two-stage search. First present
the user with a list of all OU's in your domain (usually a couple or a
few dozen), e.g. "Finance", "R&D" and so forth. Once the user has
picked the OU he wants to see, then search the users inside that
(usually a MUCH smaller number than ALL the domain users) and shows
just those in a second dropdown.
>
Quote:
Originally Posted by
>I can't use an LDAP query because lDAP isn't working on our network for
>some reason (never has. i posted a note asking help for this on the
>win2000.general newsgroup but no one replied).
>
Well, if you can't use LDAP, you're totally out of luck. Active
Directory and all the System.DirectoryServices stuff is based on LDAP.
No LDAP, no go......
>
>
So, once you've decided what to do and LDAP is working, here's how you
can do a domain-wide search - if you really want to do it in the end.
>
First you need to know what your domain is - either ask your domain
admin, or you can peek it like so (sorry, I'm fluent in C# only, so
you'll have to do the translations to VB.NET yourself or use one of
the C#-to-VB.NET translators out there on the 'net):
>
// bind to the LDAP root
DirectoryEntry root = new DirectoryEntry("LDAP://RootDSE");
>
// grab the defaultNamingContext
string myDomain = root.Properties["defaultNamingContext"].Value;
>
Next, once you have your domain name, you need to set up a domain
searcher on the domain level, and search for all users inside it:
>
DirectoryEntry domain = new DirectoryEntry("LDAP://" + myDomain);
>
DirectorySearcher dsUsers = new DirectorySearcher(domain);
>
// set up the searcher properties - search users, and return
// just their distinguishedName, givenName (first name), and
// sn (surname = family name)
>
dsUsers.Filter = "(&(objectCategory=person)(objectClass=user))";
>
dsUsers.PropertiesToLoad.Add("distinguishedName");
dsUsers.PropertiesToLoad.Add("givenName");
dsUsers.PropertiesToLoad.Add("sn");
>
Now let the searcher do its magic and find all users - you will get a
"SearchResult" object back, in which you can access all the properties
you've specified in the "PropertiesToLoad" collection:
>
List<stringallDomainUsers = new List<string>();
>
foreach(SearchResult result in dsUsers.FindAll() )
{
// grab the properties and store them somewhere, e.g. in a
// List<stringor something like that, which can then be
// bound to a combobox
string firstName = result.Properties["givenName"][0].ToString();
string lastName = result.Properties["sn"][0].ToString();
>
allDomainUsers.Add(firstName + " " + lastName);
}
>
Hope this helps you get started a bit.
>
If you have more questions, you can go to the MSDN
System.DirectoryServices portal here:
>
http://msdn.microsoft.com/library/d.../sds/portal.asp
>
There are LOTS of really good examples there, in both C# and VB.NET.
>
Or buy the excellent book by my fellow MVP's Joe Kaplan and Ryan Dunn
- really excellent stuff about Active Directory programming!
>
The .NET Developer's Guide to Directory Services Programming
(Microsoft Net Development Series)
http://www.amazon.com/gp/product/0321350170/
>
Or post here again, of course - better yet - post in the
microsoft.public.adsi.general group, that's the hard-core Active
Directory programming group.
>
Marc
Very, very informative, Marc. Thanks.
I will probably be able to translate your C# code to vb without too much
trouble. It's all similar in a way.
I helped build the domain here so I'm really familiar with the
structure. We have probably around 250 user accounts so, yea, it's way
above your recommendation of just a few dozen.
The whole purpose of this is, well, as silly as it may seem (not my deal
but asked to be done by me), is this:
The employee satisfaction workgroup has come up with this 'rock' called
the 'you rock award'. The ESQ committe wants a page on our internal
website that shows a list of all those who have had 'the rock'. In order
to take the work out of me or anyone else in the IS staff, we (my
co-worker and I) figured it would be a good idea if the individual
employee controlled what happens. After a week, the employee could hand
the rock off to someone else who the employee thinks deserves it. They
would then go to the internal website and they could use a drop down
list which would show all employess in the agency to pick the employee
the just gave the award to then click a submit button. Once they did
that, the new person would be added as the newest record in a database.
The newest record in the database would be added the top of a list on a
page which shows they got the award and when. The person in the list
right below their name is the person who gave them the award. Now, with
the new person the last record, the home page on the internal website
would now show the same drop down list of AD users so when the newly
seclected employee decided to pass on the award, they could now repeat
the same process. The person that gave them the award would, once they
gave the award away, would no longer have access to this drop down list.
The reason I wanted a drop down list is because it would be easier to
control the real AD username when using the system. The person giving
the award out may not know the actual AD username (ex. Jon Smith being
jsmith or jonsmi) and without that, it wouldn't be possible to control
the drop down list being displayed on the home page for just the person
show currently holds the award.
Feww. I hope all that made sense.
The employees wouldn't really know how to traverse the OUs in AD. No one
ever queries it directly in any way, not even through My Network Places.
The only time anyone sees a list of names is when they look through
the exchange address book in outlook.
Anyway. I think I have enough info to go forward, one way or another.
OH, and I think LDAP will work. I was trying to use WAB.exe to look at
the directory, which wouldn't work, as I was told in the active
directory news group.
Once again, Thanks Marc.
Friday, March 16, 2012
Populating DDL with Parent/Child data?
How can we populate a dropdown list with parent and child values like the forum jump dropdown at the bottom of this page?
This dropdown shows the group names and then the forum names below each group title.
Many thanks
RGHow do you get the relationship delivered? In a dataset or do you connect each time that you enter a new parent id?
You can add the items to the DDL by using Items.Add(new ListItem(..., ...));
Grz, Kris.
If you view the source of the pages of these forums, you will see that there is nothing special going on with the dropdownlist at the bottom. The subheadings and formatting are created with blank rows and such. The headings are just the same as any of the "actual" items and selecting them causes a postback (albeit a postback that does nothing).
<option value="">(please select)</option>
<option value=""></option>
<option value="/">Forums Home</option>
<option value="/search/">|- Search Forums</option>
<option value="/TopicsActive.aspx">|- Active Topics</option>
<option value="/TopicsNotAnswered.aspx">|- Unanswered Posts</option>
<option value=""></option>
<option value="User Options">User Options</option>
<option value="/user/EditProfile.aspx?ReturnUrl=/ShowForum.aspx?ForumID=18">|- My Control Panel</option>
<option value="/user/PrivateMessages/">|- My Private Messages</option>
<option value="/user/MyForums.aspx">|- My Forums</option>
<option value=""></option>
You can see some usefulsamples here.
If you don't want to code it yourself, consider using a third-party control likeEasyListBoxor Andy Smith'sListLink (free, but unsupported and not as user-friendly).
FWIW...
Populating ddl using hashtables
dropdownlist in a webform?The same way you bind any other source to a dropdownlist. Use "Key" and
"Value" as your dataTest/ValueField
ddl.DataSource = urHashtable;
ddl.DataTextField = "Value";
ddl.DataValueField = "Key";
ddl.DataBind();
--
MY ASP.Net tutorials
http://www.openmymind.net/
<shamila.thakur@.gmail.com> wrote in message
news:1129568158.495358.66850@.g14g2000cwa.googlegro ups.com...
>I have a hash table declared in a class. how do i bind it to a
> dropdownlist in a webform?
Populating ddl using hashtables
dropdownlist in a webform?The same way you bind any other source to a dropdownlist. Use "Key" and
"Value" as your dataTest/ValueField
ddl.DataSource = urHashtable;
ddl.DataTextField = "Value";
ddl.DataValueField = "Key";
ddl.DataBind();
MY ASP.Net tutorials
http://www.openmymind.net/
<shamila.thakur@.gmail.com> wrote in message
news:1129568158.495358.66850@.g14g2000cwa.googlegroups.com...
>I have a hash table declared in a class. how do i bind it to a
> dropdownlist in a webform?
>
populating ddl and setting selectedvalue
certain circumstances I want to set the SelectedValue. I've tried different
variations of this:
protected void btnImport_Click(object sender, EventArgs e)
{
[snip]
int tblcols = dsCsv.Tables["csv"].Columns.Count;
for(int i=0; i<tblcols; i++)
{
ListItem liItem = new ListItem();
liItem.Text = dsCsv.Tables["csv"].Columns[i].ToString();
liItem.Value = dsCsv.Tables["csv"].Columns[i].ToString();
ddlAddress.Items.Add(liItem);
ddlOrganization.Items.Add(liItem);
if (liItem.Text.ToLower().IndexOf("company") >=0)
{
ddlOrganization.Items.FindByText(liItem.Text).Selected = true;
}
}
}
This doesn't work. Although items were added, the code won't recognize
these items until the entire btnImport_Click is finished. How can I
accomplish this?
Thanks.Sharing ListItems is a bad idea. The problem is that Selected is a property
of an ListItem rather than the ddl the item belongs to. It means that as
soon as you select an item in one list, it will become selected also in
another list.
Create separate instances if ListItems for every list.
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"J" <nobody@.nowhere.com> wrote in message
news:13ufgs5682locff@.corp.supernews.com...
> When a button is clicked, I want to populate multiple ddl's and under
> certain circumstances I want to set the SelectedValue. I've tried
> different variations of this:
> protected void btnImport_Click(object sender, EventArgs e)
> {
> [snip]
> int tblcols = dsCsv.Tables["csv"].Columns.Count;
> for(int i=0; i<tblcols; i++)
> {
> ListItem liItem = new ListItem();
> liItem.Text = dsCsv.Tables["csv"].Columns[i].ToString();
> liItem.Value = dsCsv.Tables["csv"].Columns[i].ToString();
> ddlAddress.Items.Add(liItem);
> ddlOrganization.Items.Add(liItem);
> if (liItem.Text.ToLower().IndexOf("company") >=0)
> {
> ddlOrganization.Items.FindByText(liItem.Text).Selected = true;
> }
> }
> }
> This doesn't work. Although items were added, the code won't recognize
> these items until the entire btnImport_Click is finished. How can I
> accomplish this?
> Thanks.
>
Ah, this bit of info solves my issues. Thanks.
"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@.mMvVpPsS.org> wrote in
message news:%23GemqocjIHA.4376@.TK2MSFTNGP05.phx.gbl...
> Sharing ListItems is a bad idea. The problem is that Selected is a
> property of an ListItem rather than the ddl the item belongs to. It means
> that as soon as you select an item in one list, it will become selected
> also in another list.
> Create separate instances if ListItems for every list.
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
> "J" <nobody@.nowhere.com> wrote in message
> news:13ufgs5682locff@.corp.supernews.com...
>
Populating Drop Down Lists Based on Another DDL
wrapping the code that populates the first drop down in a
"IsPostBack==False" type check.
"Ben Arthur" <skchbs@dotnet.itags.org.yahoo.com> wrote in message
news:uHDS6CHAEHA.4080@dotnet.itags.org.TK2MSFTNGP09.phx.gbl...
> OK...assume the first ddl has 2 values"USA" & Australia", when i select
> USA, it populates the states correctly in the second ddl, but then if i
> select australia also, as it is autopostback, it comes back to USA as
> selected n so i cannot get the second DDL to populate to values for
> Australia...the datagrid however does bind correctly according to the
> states selected...
> Please let me know if I shoudl explain better....
> Thanks for ur time
> Ben
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!Yes ! Thanks, that worked...but i m not sure of how to handle
postbacks....i.e i load the first ddl only the first time, it loads the
USA and australia, then i select one of them, it loads second ddl
accordingly and builds the datagrid,but if i select australia, it
populates the second ddl but does not bind the grid.....though the
binding is not related to postback but to the selectedindexhanged(i shud
mention there is only value for the second ddl in my DB for first
ddl=australia)...is it related to the postback ...or is it because there
is only one value?
Thanks again for ur help.
Ben
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
My usual process for this is...
Put your grid-data-binding in a method/function/sub of its own. Call this
from the page load (wrapped in a isPostBack==False) then in each of your
drop down list events you can call the grid databind method.
BTW, do you really need a grid, they are very "heavy".
"Ben Arthur" <skchbs@.yahoo.com> wrote in message
news:u5jF9ZHAEHA.2800@.tk2msftngp13.phx.gbl...
> Yes ! Thanks, that worked...but i m not sure of how to handle
> postbacks....i.e i load the first ddl only the first time, it loads the
> USA and australia, then i select one of them, it loads second ddl
> accordingly and builds the datagrid,but if i select australia, it
> populates the second ddl but does not bind the grid.....though the
> binding is not related to postback but to the selectedindexhanged(i shud
> mention there is only value for the second ddl in my DB for first
> ddl=australia)...is it related to the postback ...or is it because there
> is only one value?
> Thanks again for ur help.
> Ben
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
thanks a lot...i had to put the binding code in postback part too n now
it works fine...
Thanks again
Ben
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!