|
Hmm, I got the code to work for the unique authors but I can't figure out how to populate the child nodes as I run through the dataset. I only have one table in the database so I don't think relationship would apply in my case... Where I'm confused is how do you refill a dataset based off the results of another fill..
Basically I'm wanting to fill dataset by unique author
then while the dataset is on the first author row I want to then fill the dataset based on his/her name.
and run a foreach to get all the books associated with that author. I understand that I am updating the tableadapter collection inside a foreach and it is a no no but I can't figure out how i would code this. I know it's probably not the best of design but I am still in the toddler stages of this so...
here is my code thanks
http://csharp.pastebin.com/m58597462
the second foreach is where it borks during run-time
|
|
|
|
|
Hi.
I wish to create a ASP.NET server control with design-time capabilities.
But i want to display, when designing and when rendering to a browser, some HTML code in the top which you can't edit.
How do i accomplish this?
Programming is like Mathematics… you take ONE step at the time!
|
|
|
|
|
|
The control is devoloped in C#. Which forum should i use insted?
I've searched, looked in MSDN, but can't find info or a example which covers my problem.
Programming is like Mathematics… you take ONE step at the time!
|
|
|
|
|
You are asking for an ASP.NET server control, maybe the ASP.NET forum would be the place to ask.
[DK]KiloDunse wrote: I've searched, looked in MSDN, but can't find info or a example which covers my problem
Then you haven't searched very well. No, I'm not going to do it for you either, the information is very easy to find. Try again.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
|
hi
I am ArunKumar,i am a beginner to .NET
if user enters input integer value as :5678
then output should be :5
6
7
8
** Please dont use input variable as string,input variable is int
for ex:
int x=5678; not as string x=5678;
thanks,
ArunKumar.
|
|
|
|
|
In .NET, you can easily convert the integer to string, then get each digit out. So in your example,
int x=5678;
you can declare a string variable
string sx=x.ToString();
After that you just need to use SubString() to extract each digit out of it.
|
|
|
|
|
[Just because you said you don't wanna use string]
use a different complicated process: (just for fun)
int x = 5678;
List<int> values = new List<int>();
while (x > 0)
{
int value = x - ((int)(x / 10) * 10);
values.Add(value);
x = (int)(x / 10);
}
You get all the values in the list but in reverse order. So you can use
values.Reverse();
|
|
|
|
|
int x = 5678;
string asText = string.Format("{0:0 0 0 0}", x);
string[] parts = asText.Split(' ');
for (int i = 0; i < parts.Length; i++)
{
int value = Convert.ToInt32(parts[i]);
}
EDIT ================
This is the 2nd time this week this question has come up. One of the Indian universities must have started up another semester.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
foreach(char c in x.ToString()) Console.WriteLine(c);
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
he didn't want to use a string - check my next answer...
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Here's the "pointless math exercise" version:
int value = 12345;
double i = 1;
double power = 0;
List<int> digits = new List<int>();
while (value > 0)
{
power = Math.Pow(10d, i);
digits.Add(value % (int)power);
value = (int)((double)value / power);
}
digits.Reverse();
EDIT =======================
This is clearly a homework assignment, and to be brutally honest, I see no future for you in programming. If you can't analyze and solve such a simple math problem, you have no business working as a programmer. Yeah, I provided you with the answer, but don't mistake this for a kindness on my part. In fact, I strongly advise you to share this code with your classmates, because if I see this particular request again, I cannot guarantee that I will be kind *or* understanding.
EDIT =======================
Changed digits.Sort() to digits.Reverse() .
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Saturday, January 23, 2010 7:52 AM
|
|
|
|
|
you have silently assumed the "integer" would fit in an int, in which case I agree with your code.
For larger variables, you would need long and Math.Pow() would lack the accuracy to get it right in all cases...
So the next homework assignment should be: find the smallest positive long value for which JSOP's code fails. Where is the new article category?
[ADDED]
Shall we call the final Sort a typo?
[/ADDED]
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
modified on Friday, January 22, 2010 5:53 PM
|
|
|
|
|
The OP specified an int, so it's all good.
Besides, this is just showing him how to do it, and isn't meant as an all-encompassing fulling vetted and tested method.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
And here's the pointless math exercise that accounts for negative integers:
int value = int.MinValue;
double i = 1;
double power = 0;
List<int> digits = new List<int>();
while (value != 0)
{
power = Math.Pow(10d, i);
digits.Add((value % (int)power) * ((value < -10) ? -1 : 1));
value = (int)((double)value / power);
}
digits.Reverse();
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Saturday, January 23, 2010 8:27 AM
|
|
|
|
|
And finally, the pointless math exercise extracting the digits from left to right instead of right to left.
bool isNegative = (value < 0);
List<int> digits = new List<int>();
int value = int.MinValue;
double i = 9;
double power = 0;
while (value != 0)
{
power = Math.Pow(10d, i);
int result = (value - (value % (int)power));
int addResult = (int)((double)result / power) * ((isNegative && (int)i == 9) ? 1 : -1);
digits.Add(addResult);
value -= result;
i--;
}
I hope you can see by my persistence that I've found several similar ways to accomplish the stated goal. This is part of what makes a good programmer.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
hi guys
i want to know how to get output of SSRS(another project in the same solution) to win form using c# language (in the same solution) with visual studio 2008
so any articles or answers can help me
thanks
|
|
|
|
|
I'm sorry everyone but I posted the wrong problem so here it goes again..
When you try to set the rightToLeft property inside the modal form, it vanishes..
this.RightToLeft = RightToLeft.Yes;
It's obvious, it's a bug.. Can you think of any workaround??
Thank you everyone!
|
|
|
|
|
HA HA HA... how many times are you gonna change your question?
anyways, yes, looks like changing this property is sending a dialog result somehow add a this.DialogResult = DialogResult.None; after your this.RightToLeft = RightToLeft.Yes; .
So it becomes:
this.RightToLeft = RightToLeft.Yes;
this.DialogResult = DialogResult.None;
|
|
|
|
|
It works, though I lose focus of the calling form.
|
|
|
|
|
did you do this? if you are loosing focus even after this, i gotta give up because i tested this code.
I am typing it here so check for spell errors.
Original Form:
TestForm form = new TestForm ();
form.ShowDialog();
Modal Form:
public partial class TestForm : Form
{
public TestForm()
{
InitializeComponent();
ChangeRightToLeft();
}
private void ChangeRightToLeft()
{
this.RightToLeft = RightToLeft.Yes;
this.DialogResult = DialogResult.None;
}
}
|
|
|
|
|
Put
this.RightToLeft=RightToLeft.Yes;
in the dialog class' constructor instead of the form_load handler. That will solve the problem and a DialogResult.None will not be returned.
|
|
|
|
|
Works fine in the form's load handler. I don't believe the disappearing has anything to do with changing this property.
/ravi
|
|
|
|