• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Should be simple



I am trying to set a variable to the value in a dataset column/row

here is the code that i have


                                                string delimStr = ",.:";
                  char [] delimiter = delimStr.ToCharArray();
                  int x = 10;
                  string locations = dsLogins1.Tables[0].Columns["locations"].ToSring();
                  string [] splitlocations = locations.Split(delimiter , x);
                  foreach (string s in splitlocations)

The locations value that is held in the table is something like 23,100,241,221

When I do a debug and view the variable value of locations, it just is a string "locations"

How do I set the value of this to the variable?

Thanks,
Justin
0
jlazanowski
Asked:
jlazanowski
  • 4
  • 2
1 Solution
 
sharpnetCommented:
Instead of referencing dsLogins1.Tables[0].Columns["locations"], which just gives you the column info, you need to be pointing to the row.  It should read :

sdLogins1.Tables[0].Rows[<index of row>]["locations"]

where <index of row> is the row you want.  For testing this can simply be 0.

Let me know if this works.  If not, please paste a large portion of your script (including the DataSet setup) so I can run a debug from here.

Nick
0
 
sharpnetCommented:
oh, and don't forget the ToString() at the end of that statement.  I had removed for clarity.

Nick
0
 
jlazanowskiAuthor Commented:
I put it on there..

One more questions semi related.

first I am using a drop down box to select a value. This dropdown is bound to the dataset (this is done in the desinger)

when the user presses a select button it binds to text boxes and a few check boxes to values in the dataset (the row the user selected)

My problem is how do I know what row the user selected, since this wasn't done in code but in the designer I am not aware of the row index.

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
sharpnetCommented:
well, the follow up question should technically be a new question in the forums since it's a different type of question.  Just fair for the points...

But, my first thoughts are that when a user selects something from the dropdown box, they are not actually selecting a "row" from the dataset.  What you'll have to do is find the selectedindex or selecteditem from the dropdown box and, via code, find the row containing that information and make changes from there.  It shouldn't matter if your dataset and dropdown are bound via code or the designer, you're still looking at "item" objects from the dropdown box.  

If you make a new post for this question and paste some of your code, I can help you more with it.

Nick
0
 
jlazanowskiAuthor Commented:
Nick,

Would you do me a favor and look at
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21368848.html

I am not getting the anwser that I am looking for and I though maybe a fresh set of eyes could help.

Thanks
0
 
sharpnetCommented:
Yeah, I'll give it a shot.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now