Click here to Skip to main content
15,914,447 members
Home / Discussions / C#
   

C#

 
GeneralSmart Device Application Pin
mathon21-Sep-04 9:53
mathon21-Sep-04 9:53 
GeneralRe: Smart Device Application Pin
Heath Stewart21-Sep-04 11:12
protectorHeath Stewart21-Sep-04 11:12 
GeneralRe: Smart Device Application Pin
Chris Quick21-Sep-04 12:17
Chris Quick21-Sep-04 12:17 
GeneralRe: Smart Device Application Pin
mathon21-Sep-04 13:53
mathon21-Sep-04 13:53 
GeneralRe: Smart Device Application Pin
Heath Stewart21-Sep-04 14:31
protectorHeath Stewart21-Sep-04 14:31 
GeneralRe: Smart Device Application Pin
mathon21-Sep-04 22:08
mathon21-Sep-04 22:08 
GeneralHelp on setting index of dropdownlist. Pin
macsgirl21-Sep-04 9:46
macsgirl21-Sep-04 9:46 
GeneralRe: Help on setting index of dropdownlist. Pin
Colin Angus Mackay21-Sep-04 12:00
Colin Angus Mackay21-Sep-04 12:00 
01: string strStore 
02: ListItemType oType = ((ListItemType)e.Item.ItemType); 
03: if ((oType == ListItemType.EditItem)) 
04: { 
05:     Response.Write("The ItemDataBound Command has been fired"); 
06:     DropDownList listStore = ((DropDownList) e.Item.FindControl("ddlStores")); 
07:     strStore = ((DropDownList)(e.Item.FindControl("ddlStores"))).SelectedItem.Text; 
08:     Response.Write (strStore); 
09:     // listStore.SelectedIndex = Convert.ToInt32(strStore); 
10:     listStore.Items.IndexOf(listStore.Items.FindByText(strStore)); 
11:     Response.Write(listStore.Items.IndexOf(listStore.Items.FindByText(strStore))); 
12: }


I'm having difficulty trying to read your code here. I've numbered the lines for ease of reference.

Line 1: Missing semi-colon;
Line 2: e.Item.ItemType[^] already returns an object of type ListItemType so I am curious as to why you are casting it.
Line 5: I am assuming this is for debugging only. If so, a better mechanism would be setting up tracing. See: Enabling Tracing for a Page[^] and Writing Trace Messages[^]
Line 7: Finding the control again is redundant here because you did that on line 6. Change the line to strStore = listStore.SelectedItem.Text
Line 8: See previous comments on tracing
Line 10: You perform an IndexOf operation but do not store the value anywhere.
Line 11: You perform the same IndexOf operation again.

Now, to answer your question:
On line 6 you get the DropDownList, once you have this you can use the SelectedIndex[^] property to get the index of the selected item.

Does this help?


Do you want to know more?

Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!


GeneralRe: Help on setting index of dropdownlist. Pin
macupryk21-Sep-04 12:32
macupryk21-Sep-04 12:32 
GeneralRe: Help on setting index of dropdownlist. Pin
Colin Angus Mackay21-Sep-04 12:47
Colin Angus Mackay21-Sep-04 12:47 
GeneralRe: Help on setting index of dropdownlist. Pin
macupryk21-Sep-04 13:00
macupryk21-Sep-04 13:00 
GeneralRe: Help on setting index of dropdownlist. Pin
Colin Angus Mackay21-Sep-04 13:12
Colin Angus Mackay21-Sep-04 13:12 
GeneralConfigurable font height/width Pin
Yaron K.21-Sep-04 7:44
Yaron K.21-Sep-04 7:44 
GeneralRe: Configurable font height/width Pin
Heath Stewart21-Sep-04 11:33
protectorHeath Stewart21-Sep-04 11:33 
GeneralRe: Configurable font height/width Pin
Yaron K.21-Sep-04 19:01
Yaron K.21-Sep-04 19:01 
GeneralRe: Configurable font height/width Pin
Yaron K.22-Sep-04 22:37
Yaron K.22-Sep-04 22:37 
Generalproblem with c# (help required) Pin
Anonymous21-Sep-04 7:30
Anonymous21-Sep-04 7:30 
GeneralRe: problem with c# (help required) Pin
tdciDoug21-Sep-04 10:39
tdciDoug21-Sep-04 10:39 
GeneralRe: problem with c# (help required) Pin
Christian Graus21-Sep-04 10:44
protectorChristian Graus21-Sep-04 10:44 
GeneralHelp with books Pin
krisst_k21-Sep-04 7:21
krisst_k21-Sep-04 7:21 
GeneralRe: Help with books Pin
Werdna22-Sep-04 6:18
Werdna22-Sep-04 6:18 
GeneralC# Downloader Pin
shiraztk21-Sep-04 7:11
shiraztk21-Sep-04 7:11 
GeneralRe: C# Downloader Pin
Dave Kreskowiak21-Sep-04 8:34
mveDave Kreskowiak21-Sep-04 8:34 
GeneralRe: C# Downloader Pin
Alex Korchemniy21-Sep-04 10:24
Alex Korchemniy21-Sep-04 10:24 
GeneralRe: C# Downloader Pin
Heath Stewart21-Sep-04 11:16
protectorHeath Stewart21-Sep-04 11:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.