Hi all,
I hope someone can help with this relatively simple problem.
I am building a timesheet application using ASP.NET C# with Visual
Studio 2003.As it is only a protoype application, my database has been
made in MSDE.
As part of my application, I have a 'Resources' table, which holds
employee information. I have the fields FirstName and LastName which
are entered in my data capture form which works fine. The problem
however, is that on other forms, for example, I wish to be able to
select employees from a drop-down list which shows both their first and
last names. At present my drop-down lists can only showHow should I go
about this? Can I create a view or something to achieve this? Or could
I insert a 'FullName'colum n into my 'Resources' table, which is set by
default to take the first and last names of each new resource and
concatanate it into one string? I worked on an application previously,
which seemed to do something similar, although I don't know how.
What I did try originally was to show the resource information on the
form as a DataGrid, but was unable to successfully pass the
SelectedItem when my 'submit' button was pressed.
Any thoughts, suggestions would be much appreciated!
Thanks again
Al 9 1724
If you have an employee class, you can add a FullName get property, and
then databind to that. You can even get clever and have a FormatName
method which returns names as Surname, Firstname; Firstname Surname;
etc.
public class Employee
{
public string FirstName
{
get {}
set {}
}
public string Surname
{
get {}
set {}
}
public string FullName
{
get { return string.Format(" {0} {1}", FirstName, Surname); }
}
}
If I undertand your Question right.. this is simply done in your query
"Select ID, Firstname+' '+LastName AS FullName From Employees";
in your code you may use reader or dataset, For me i use datareader.
using(SqlDataRe ader dr = cmd.ExcuteReade r(CommandBehvio ur.CloseConnect ion)
{
while(dr.Read() )
{
ddl1.Items.Add( new ListItem(dr.Get String(0),dr.Ge tInt32(1)))
}
dr.Close();
}
"thebison" <al************ @btinternet.com > wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com... Hi all,
I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my database has been made in MSDE.
As part of my application, I have a 'Resources' table, which holds employee information. I have the fields FirstName and LastName which are entered in my data capture form which works fine. The problem however, is that on other forms, for example, I wish to be able to select employees from a drop-down list which shows both their first and
last names. At present my drop-down lists can only showHow should I go about this? Can I create a view or something to achieve this? Or could I insert a 'FullName'colum n into my 'Resources' table, which is set by default to take the first and last names of each new resource and concatanate it into one string? I worked on an application previously, which seemed to do something similar, although I don't know how.
What I did try originally was to show the resource information on the form as a DataGrid, but was unable to successfully pass the SelectedItem when my 'submit' button was pressed.
Any thoughts, suggestions would be much appreciated!
Thanks again
Al
Hi everyone!
Thanks, that is exactly what I wanted. My drop-down list now shows the
FullName and it looks great!
While I have your attention....pe rhaps any of you could assist with
another issue I am having on the same form. The basic point of this
form is to assign a Resource (Employee) onto a Task, which has
previously been assigned to a Project. The way I have laid the form out
is that you can select Projects, Tasks, and Employees all from
drop-down lists. The user can then add some dates, and click submit to
send it to the database.
My problem is that I want the Task drop-down list to automatically
repopulate with the correct tasks when the user selects a Project from
the Project drop-down. What I mean by this is that if for example the
user selects "Redistribu tion Project" from the list, then only tasks
from that Project will be available in the Tasks drop-down.
I believe I will have to do something with my page_load, specifically
the IsPostBack part...but I am not sure exactly. My code is currently:
if(!IsPostBack)
{
this.sqlDataAda pter1.Fill(this .dsProjectName1 );
ddProjectName.D ataBind();
this.sqlDataAda pter3.Fill(this .dsTaskName1);
ddTaskName.Data Bind();
this.sqlDataAda pter4.Fill(this .dsResourceFull Name1);
ddResName.DataB ind();
sqlConnection1. Close();
}
Any help greatly appreciated!
Thanks
Al
Well initially you have to load you Projects in the dropdown list so
that should go in the !IsPostBack. However, the other two are loaded
on demand when a user select a project. So, Your dropdown list for
your project should have autopostback = true. Then,
you must load the TaskName items in the SelectIndexChan ged event for
the ddProjectname using the value for the dropdown list of the
projectnames as the filter criteria. The same goes if you want to load
the ResourceName ddl on demand.
Hi again,
Thanks for your help, I have managed to put the relevant ddls in the
right place so that they are posting back at the right time (using the
SelectedIndexCh anged part of the code). However I cannot quite get my
RowFilter to work. I'm not sure exactly what I should be putting in
there.
Basically I am populating the Task drop-down list with a DataView. So I
need a RowFilter for the Tasks that filters the TaskID to only show
those that have the same ProjectID as selected from the Project
Drop-Down List.
Something like... dataView3.RowFi lter = "Task.Proje ctID =
(ddProjects.Sel ectedValue) ";
The ddProjects is passing the ProjectID as its DataValueField.
Any help appreciated, as ever!
Thanks
Al
The code you wrote for filtering is ok.
I can see that you bind your dropdownlists visually, and generate typed
dataset.. and also the views..
Here is the the code i may use:
DataView dv = dsTaskName1.Tab les[0].DefaultView;
ddTaskName.Data Source = dv;
ddTaskName.Data TextField = ..
.......
dataView3.RowFi lter = "Task.Proje ctID =" + ddProjects.Sele ctedValue
ddTaskName.Data bind();
this will work.. give it a try..
PS... check this usefull link http://msdn.microsoft.com/practices/...s/default.aspx
"thebison" <al************ @btinternet.com > wrote in message
news:11******** **************@ t31g2000cwb.goo glegroups.com.. . Hi again,
Thanks for your help, I have managed to put the relevant ddls in the right place so that they are posting back at the right time (using the SelectedIndexCh anged part of the code). However I cannot quite get my RowFilter to work. I'm not sure exactly what I should be putting in there.
Basically I am populating the Task drop-down list with a DataView. So I need a RowFilter for the Tasks that filters the TaskID to only show those that have the same ProjectID as selected from the Project Drop-Down List.
Something like... dataView3.RowFi lter = "Task.Proje ctID = (ddProjects.Sel ectedValue) ";
The ddProjects is passing the ProjectID as its DataValueField.
Any help appreciated, as ever!
Thanks
Al
Hi,
Thanks, I have this working now! :-)
I now have another question, I've searched all over the web for the
answer, but can't quite work it out. I am filling a list-box with
'Start Date' and 'Finish Date' from a table, and have concatanated
these into a new field, 'Full Date'. However when I DataBind the
list-box it shows the format as '01/10/06 12:00:00 - 07/10/06
12:00:00'. I do not want the times to show. I know how to format one
column, using the DataTextFormatS tring property, setting it to {0:d} ,
but I can't work out what it will need to be for my 'Full Date' field.
The actual data expression for 'Full Date' is
StartDate + '-' + FinishDate
And I wish it to show in the ListBox as '01/10/06 - 07/10/06'.
Anyone have any ideas on what I should put into DataTextFormatS tring to
achieve this?
Many Thanks!
Al
this artcile should help http://www.codeguru.com/csharp/cshar...cle.php/c4205/
Also i think try formatting the date values before adding it to your listbox
do it in the code behind or try looking at string.Format
Patrick
"thebison" <al************ @btinternet.com > wrote in message
news:11******** **************@ e56g2000cwe.goo glegroups.com.. . Hi, Thanks, I have this working now! :-)
I now have another question, I've searched all over the web for the answer, but can't quite work it out. I am filling a list-box with 'Start Date' and 'Finish Date' from a table, and have concatanated these into a new field, 'Full Date'. However when I DataBind the list-box it shows the format as '01/10/06 12:00:00 - 07/10/06 12:00:00'. I do not want the times to show. I know how to format one column, using the DataTextFormatS tring property, setting it to {0:d} , but I can't work out what it will need to be for my 'Full Date' field.
The actual data expression for 'Full Date' is StartDate + '-' + FinishDate
And I wish it to show in the ListBox as '01/10/06 - 07/10/06'. Anyone have any ideas on what I should put into DataTextFormatS tring to achieve this?
Many Thanks!
Al
Hi,
Thanks for your reply. I think the reason I am having a problem is that
my 'FullDate' column is being defined as a string, made up of
"StartDate and FinishDate', as shown below:
StartDate + '-' + FinishDate
This means that if it is a string, applying Date Formatting such as
{0:d} (as in the article you suggested) does nothing. When I set the
data type of 'FullDate' to be DateTime, I get the following error
'Cannot convert value '13/03/2006 00:00:00- 19/03/2006 00:00:00' to
Type: System.DateTime .'
So what I am trying to do is cast a string into a DateTime column,
which won't work, obviously. Is there any other way I can accomplish
this?
Many thanks
Al This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Neil Ginsberg |
last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC
linked tables. I recently created a new set of tables for the app, and users
are complaining that unsaved data is being lost when they move to a new
record. This seems to be the case when there are multiple users. When there
is a single user using it, we don't seem to have that problem.
It seems that we had this problem when we first converted from an MDB back
end...
|
by: David C. Barber |
last post by:
upsized an MDB to ADP/SQL Server 2000 under Access 2000. All the DAO code
that I've changed to ADO code is working fine, HOWEVER the form Record
Source itself does not seem willing to return data. I've set the Record
Source to both the query, and the SQL contained within the query, and
although the system pauses long enough to have gone out and retrieved the
data, I can't see it. The form itself remains gray. In addition:
...
|
by: sparks |
last post by:
They have a new data collection station. The people here are using
access 97....
This third party site will only post data back to us when we do this.
http://www.datastuff.com/cgi-bin/ocs?Lo=yourname&Rpt=703&Month=7-5&Select=CC
this is posted back to us as a file called data.
There is no extension to is so the first thing that IE does is ask to
save and where.
|
by: Johann Blake |
last post by:
I am looking for a good solution on how to implement data access in an
application so that there is a clean separation between the data access
layer, the business layer and the GUI layer. I am looking for a robust
solution for a major application. Almost every developer seems to come
up with a completely different solution. While many of them are not
bad, I really want a very good one.
My database is SQL Server 2000 and I am using Visual...
|
by: philip |
last post by:
On a form, I have a datagridview.
This datagridview is constructed on a dataset filled by a tableadapter.
The table adapter do very well what it must do when filling dataset.
Insertions, modifications and deletions functions very well in the dataset.
But impossible to transmit modifications in ACCESS database. Impossible to
WRITE in database.
Here is the code for data transmission from tableadapter to Access database
:
| |
by: SRAM |
last post by:
Hi,
Problem statement: We have some amount of data stored in various excel
sheets and we generate a few reports from these data. We are in the
process of consolidating all data to reside in a single repository.
Currently, it is semi-automated i.e. we are using MS Excel for data
entry, consolidation and report generation (i.e. using formulas). We
require a tool that will provide:
a) A web-based interface for data entry (i.e. remote,
|
by: Grip |
last post by:
Hi,
I have gone throught the group and Microsoft's online help and have
seen many suggestions but I am still seeking clarity:
1. I have an excel spreadsheet. Column A contains text that may be
greater than 255 characters.
2. I have an access database. I link (not import) to the contents of
the excel spreadsheet. In the design view in access, Column A has the
data type "memo".
|
by: Chad |
last post by:
Hi
Is it possible to substitute an alternative data source (eg MySQL or
SQL Server) into an existing MS-Access application?
|
by: Joe Salmeri |
last post by:
I have found a data corruption problem with pyodbc.
OS = Windows XP SP2
DB = Microsoft Access XP
PROBLEM:
When selecting columns from a table that are of type Memo the value
returned is padded with a bunch of null characters at the end.
|
by: Wesley Peace |
last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having
with visual studio 2008.
I've created a series of forms with controls to access a Access database
tables. The connection string works fine and the tables are added to the
project without a problem.
When I create the tables they appear to bind and I am able to preview the
data in the database in design mode; however, at runtime no data is
displayed and the...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |