CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_web_developer_2005_express Tags:
Item Type: NewsGroup Date Entered: 6/20/2007 4:42:00 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 32 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
Suryansu
Asp.Net User
Creating dynamic array,adding stringsinto the array and retrieving string6/20/2007 4:42:00 AM

0/0

hi,

I want to create a dynamic array which will contain string......then dynamically I will add strings to the array....At the end how i will retrieve strings from that array......

for example....i have a textbox, a button named add, and a button named show...... 1st i will write some string in the textbox....whene i click on the ADD button.the string wriiten in the textbox will be added to the array.....again i will write another string in textbox...again click the ADD button....that will be added to the array.................

so at the end when i click on the SHOW button, I want to see all the strings which i have entered.........

gridview
Asp.Net User
Re: Creating dynamic array,adding stringsinto the array and retrieving string6/20/2007 5:08:29 AM

0/0

Code behind should be as : 

Sub AddButton_Click(ByVal sender As Object,ByVal e As System.EventArgs)

Dim sMyArray As String= New String()

sMyArray()=TextBox1.Text


End Sub

 

Sub ShowButton_Click(ByVal sender As Object,ByVal e As System.EventArgs)

Dim Value As String


For Each value As String In sMyArray

Response.Write(value)


Next

End Sub

eyad.salamin
Asp.Net User
Re: Creating dynamic array,adding stringsinto the array and retrieving string6/20/2007 5:15:53 AM

0/0

for dynamic allocation of a list of objects you need to use either generics or ArrayList 


if we used generics plus session to maintain the value between postbacks the code beside would be something like:

 

 

using System.Collections.Generic;
using System;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
private List<string> ResultArray
{
get
{
if (Session["resultArray"] == null)
Session["resultArray"] = new List<string>();
return (List<string>)Session["resultArray"];
}
}

protected void btnAdd_Click(object sender, EventArgs e)
{
ResultArray.Add(txtNewText.Text);
txtNewText.Text = string.Empty;
}
protected void btnShow_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
foreach (string s in ResultArray)
{
sb.Append("<br />" + s);
}
lblResultingText.Text = sb.ToString();
}
}

 of course I don't recommend using session between post backs to the same page, rather, I recommend adding the strings to a comma separated string and storing it in the view state.

<%= Eyad.Salamin %>

<aspForums:DontForget>Don't forget to click on Mark as answer on the post that helped you.

This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. </aspForums:DontForget>
JeffreyABecker
Asp.Net User
Re: Creating dynamic array,adding stringsinto the array and retrieving string6/20/2007 12:37:19 PM

0/0

From a UI perspective, why wouldn't you use a text input + a select?  The select would hold the individual strings and have the added bonus of displaying them and letting you delete specific ones.

4 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Creating dynamic array,adding stringsinto the array and retrieving ... Creating dynamic array,adding stringsinto the array and retrieving string. Last post 01-21-2008 10:00 AM by rjcox. 10 replies. Sort Posts: ...
ng.asp-net-forum.data_access-mysql/3 - Web Programming Newsgroups creating dynamic array,adding stringsinto the array and retrieving string · hide non-virtual property · destinationpageurl issur · bug report location ...
An Introduction to Programming Using Microsoft Visual Basic .NET Join(separator, stringArray) concatenates the elements of an array of Stringsinto a single. string with a designated separator between the elements. ...
roven's Blog Creating dynamic array,adding stringsinto the array and retrieving string. PostAt:Tue, 30 Sep 2008 10:39:58 GMT. hi,I want to create a dynamic array which ...
Creating dynamic array,adding stringsinto the array and retrieving ... Creating dynamic array,adding stringsinto the array and retrieving string. Last post 01-21-2008 10:00 AM by rjcox. 10 replies. Sort Posts: ...
ng.asp-net-forum.data_access-mysql/3 - Web Programming Newsgroups creating dynamic array,adding stringsinto the array and retrieving string · hide non-virtual property · destinationpageurl issur · bug report location ...
An Introduction to Programming Using Microsoft Visual Basic .NET Join(separator, stringArray) concatenates the elements of an array of Stringsinto a single. string with a designated separator between the elements. ...
roven's Blog Creating dynamic array,adding stringsinto the array and retrieving string. PostAt:Tue, 30 Sep 2008 10:39:58 GMT. hi,I want to create a dynamic array which ...
Creating dynamic array,adding stringsinto the array and retrieving ... Creating dynamic array,adding stringsinto the array and retrieving string. Last post 01-21-2008 10:00 AM by rjcox. 10 replies. Sort Posts: ...
ng.asp-net-forum.data_access-mysql/3 - Web Programming Newsgroups creating dynamic array,adding stringsinto the array and retrieving string · hide non-virtual property · destinationpageurl issur · bug report location ...




Search This Site:










several tables missing in pubs database

any problem running a website on vs created in vwd

debug not working in ie7

req/help: vwd documentation tool

can't connect to access data base with asp.vb code behind page

web hosting

web part verb menu question

can we split the input of a date into tree section?

access is denied on my own machine

looking for beginner info

database

where can i get some free programs written by vwd?

publish asp.net web page with data folder

compiling in 1.1

i want to build a website: but i'm a noob!!!!

the asp.net 2.0 web application made by chinese windows xp + english microsoft visual web developer 2005 express edition can't run under english edition windows xp ?

connection with microsoft sql 2000

scrolling value from database

web site with visual web developer 2005 express

code behind pages?

3rd party controls

views in database explorer

vwd open web site

creating a centralized dll and migrating to visual studio 2005 from visual web developer express edition

why is this code not populating outlook email addresses in my dropdownlist

asp.net configuration------->> please help

table im masperpage

tables!!!

new dll in project

deploy to intranet

  Privacy | Contact Us
All Times Are GMT