Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Monday, March 26, 2012

Populate array from a dataset ?

Can someone point me to an example of populating an array from a dataset ?

This .net stuff is killing me.What are you trying to do in more detail? What goes in each element of the array? What about multiple tables?

Not that I'm a Datset fan but you have a lot more functionality with your data in a dataset than an array.

Populate Database from Arraylist

I would like to know how to Populate the SQL Database column using the Arraylist

I'm sure its gonna be INSERT...one example i need

INSERT INTO tempPrice(price) VALUES ( "...............")

How should i declare Arraylist in it? I have a list of values inside the arraylist and i just want the entire column to be filled with it.

Thanks.

HTM

Unfortunately there is no direct way to do this. You have to execute each sql query for each row.

Regards

Saturday, March 24, 2012

Populate fields

Hi:

I am looking for lookup table ability so the user will not have re-enter student information data. I have a table called for example "StudentInfo" - lookup table and another table called StudentActivity. My environment is VS.net/SQL/C#

I would like to have a form that would allow user to to select specific student (eg. from the drop down or listbox from StudentInfo table) and populate StudentActivity table based fields with the values from StudentInfo table, based on user selection.

ENTRY FORM (bound to StudentActivityTable)

Select Student: drop down menu (from StudentInfo)

Student name (populated from StudentInfo)

Student age (populated from StudentInfo)

Student address (populated from StudentInfo_

Location (user input)

Date: (user input) etc.

I would appreciate your assistance.

Danka

You need to get to grips with the basics of data access. http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/default.aspx

Here is a tutorial that is doing something like what you describe. It pairs a DropDownList with a DetailsView: http://msdn2.microsoft.com/en-us/library/aa581790.aspx

The DetailsView displays individual records, and can be used to edit or delete them. If the DetailsView control doesn't give you what you want, you could try the FormView control. I think the FormView offers greater flexibility in formatting the appearance.

Hope this helps


Yes, this is a good introduction for me. Thanks.


Hi:

I implemented it as a find compnay feature that provides user with a view of detailed company information based on the company selection in the drop down list.

Regarding my previous question related to drop down selection I tried the following code on someones advise. When user selects a value from the pull down menu this code updates templated field which is bound to database field. In the insert template I made this control not visible. I probably could implement the same on the edit template. It should be a better way than this. I am all new to it so I would appreaciate your thoughts.

} protectedvoid DropDownList1_SelectedIndexChanged(object sender,EventArgs e) { TextBox txtName = (TextBox)DetailsView1.FindControl("txtInsertLegalCompanyName"); DropDownList ddlName = (DropDownList)DetailsView1.FindControl("DropDownList1"); txtName.Text = ddlName.SelectedValue;

Now, I also have radio buttons list with two values Yes and No (true and false). I need some piece of code that would allow to show the selected value on the edit template (yes or no). Check box list allow to select both values True and False so I probably need some piece of code here so if one is selected the other one is deselected. I would also like to dispay Yes instead true, in vb I would use IIF... statment...

Your help would be appreaciated.

Friday, March 16, 2012

Populating data in classes

Hi all,

I have 2 classes, for example. I have a Company class and a contact
class.

each class has the following properties

Company
ID
Name
Town
Ref

Contact
CompanyID
FirstName
LastName
Email

Now if i am retrieving the data from my database and filling the
contact class, is it ok to populate the contacts companyname, for
example

Contact.FirstName = "XXX"
Contact.lastname = "XXX"
Contact.Company.ID = 99
Contact.Company.Name = "XXXX"

Is this best practice, or should i be doing this another way? I
thought this would make sense to do, as most of the time if i have a
contact class, i usually want to show the companyName.

Anyone know of a better way to do this, or the "best practice way"??
CheersOr maybe it would be better to write another New constructor that
accepts the ID and Name?

Contact.firstname = "ZZZ"
Contact.Lastname = "CCC"

Contact.Company = New Company(99, "CCCCC")

Is this a better option?
Yes. This is a better option. Other than that, you look fine.

"Nemisis" <darrens2005@.hotmail.comwrote in message
news:1158670936.010052.6720@.d34g2000cwd.googlegrou ps.com...

Quote:

Originally Posted by

Or maybe it would be better to write another New constructor that
accepts the ID and Name?
>
Contact.firstname = "ZZZ"
Contact.Lastname = "CCC"
>
Contact.Company = New Company(99, "CCCCC")
>
Is this a better option?
>


tdavisjr wrote:

Quote:

Originally Posted by

Yes. This is a better option. Other than that, you look fine.
>

Quote:

Originally Posted by


Contact.firstname = "ZZZ"
Contact.Lastname = "CCC"

Contact.Company = New Company(99, "CCCCC")

Is this a better option?


Tdavis,

Thanks for the reply, i do agree with you, because it looks neater, but
do you have any other reason why you think this is better?