Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > it's all about semantics

Reply
Thread Tools

it's all about semantics

 
 
=?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=
Guest
Posts: n/a
 
      07-13-2004
Hi
Instead of a direct opinion on the following matter I prefer to post it as a quiz. What do you expect the code below does:

---

ListItem[] litems = new ListItem[5];
for (int i = 0; i < 5; i++)
litems[i] = new ListItem("text"+i,"value"+i);

DropDownList ddl;
for (int j = 0; j < 3; j++)
{
ddl = new DropDownList();
ddl.Items.AddRange(litems);
//assume PlaceHolder1 exists on WebForm
PlaceHolder1.Controls.Add(ddl);
}
//Now the tricky part - set selectedIndex for 2nd dropdownlist control, let's say:
((DropDownList)PlaceHolder1.Controls[1]).SelectedIndex = 0;

---

So, what do you think is the outcome of the above code?
What do you think of the code/effect semantics in this case?

dimitris
 
Reply With Quote
 
 
 
 
Scott G.
Guest
Posts: n/a
 
      07-13-2004
I'll answer with a quiz: Do you think that "sharing" ListItems in multiple DropDownLists would do something different than set the SelectedItem for all three DropDownLists?

Scott
"Dimitris Pantazopoulos" < > wrote in message news:93C6FC02-F849-4B02-9D46-...
Hi
Instead of a direct opinion on the following matter I prefer to post it as a quiz. What do you expect the code below does:

---

ListItem[] litems = new ListItem[5];
for (int i = 0; i < 5; i++)
litems[i] = new ListItem("text"+i,"value"+i);

DropDownList ddl;
for (int j = 0; j < 3; j++)
{
ddl = new DropDownList();
ddl.Items.AddRange(litems);
//assume PlaceHolder1 exists on WebForm
PlaceHolder1.Controls.Add(ddl);
}
//Now the tricky part - set selectedIndex for 2nd dropdownlist control, let's say:
((DropDownList)PlaceHolder1.Controls[1]).SelectedIndex = 0;

---

So, what do you think is the outcome of the above code?
What do you think of the code/effect semantics in this case?

dimitris
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=
Guest
Posts: n/a
 
      07-14-2004
I think it is not a logical "sharing" practice in this case.

whoever engineered that was loco.

dimitris


"Scott G." wrote:

> I'll answer with a quiz: Do you think that "sharing" ListItems in multiple DropDownLists would do something different than set the SelectedItem for all three DropDownLists?
>
> Scott
> "Dimitris Pantazopoulos" < > wrote in message news:93C6FC02-F849-4B02-9D46-...
> Hi
> Instead of a direct opinion on the following matter I prefer to post it as a quiz. What do you expect the code below does:
>
> ---
>
> ListItem[] litems = new ListItem[5];
> for (int i = 0; i < 5; i++)
> litems[i] = new ListItem("text"+i,"value"+i);
>
> DropDownList ddl;
> for (int j = 0; j < 3; j++)
> {
> ddl = new DropDownList();
> ddl.Items.AddRange(litems);
> //assume PlaceHolder1 exists on WebForm
> PlaceHolder1.Controls.Add(ddl);
> }
> //Now the tricky part - set selectedIndex for 2nd dropdownlist control, let's say:
> ((DropDownList)PlaceHolder1.Controls[1]).SelectedIndex = 0;
>
> ---
>
> So, what do you think is the outcome of the above code?
> What do you think of the code/effect semantics in this case?
>
> dimitris

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Semantics extractor Luigi Donatello Asero HTML 5 02-14-2004 07:10 PM
Objects with value semantics - enums vs classes David Rasmussen C++ 4 01-12-2004 12:13 AM
Equivalency Semantics, Operator Overloading Grant Austin C++ 3 12-09-2003 05:03 PM
std::vector<>::clear semantics Stefan Höhne C++ 10 10-17-2003 09:50 AM
destructor / semantics of delete this Alexander Stippler C++ 6 08-20-2003 03:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57