August 21, 2005 at 11:00 pm
------------
string strSource;
foundVendors = appVendTable.Select("Item = '" + [foundRows.Length-1]["COMPONENT"].ToString()
+ "'");
if (foundVendors.Length == 0)
{
strSource = "None";
//rangeSOURCE.Value2 = "None";
//outputStr.Append("<TD>=\""+"None"+ "\"</TD>");
}
if (foundVendors.Length == 1)
{
strSource = "Single";
//rangeSOURCE.Value2 = "Single";
//outputStr.Append("<TD>=\""+"Single"+ "\"</TD>");
}
if (foundVendors.Length > 1)
{
strSource = "Multiple";
//rangeSOURCE.Value2 = "Multiple";
//outputStr.Append("<TD>=\""+"Multiple"+ "\"</TD>");
}
------------
I am delclaring a string variable like "string strSource;" before using it in the
if-conditions.Then at the end I want to iterate through the dataset and then append it using stringbuilder.
----------
foreach (DataRow pRow in mlBomDS.Tables["ITEM_MULTILEVELBILL"].Rows)
{
outputStr.Append("<TR>");
outputStr.Append("<TD>" + strSource + "</TD>");
outputStr.Append("<TD>=\""+foundItems[0]["LOT_SZ_MUL"].ToString()+ "\"</TD>");
outputStr.Append("</TR>");
}
-----------
So my problem is, it only Appends the "strSource" instead of the value based on the
if-Condition.
"FoundVendors" and "FoundItems" are DataRow type.
My another Problem is when I append
outputStr.Append("<TD>=\""+foundItems[0]["LOT_SZ_MUL"].ToString()+ "\"</TD>");
It is only able to append one single value for all rows.
If I try to intialize "int i" and then place
outputStr.Append("<TD>=\""+foundItems["LOT_SZ_MUL"].ToString()+ "\"</TD>");
Then it complains that the "array is out of bound."
How do I get it to append different values for different rows of the datatable.
Thanks for your help in advance!
August 25, 2005 at 12:27 pm
First, strSource is a String, not a StringBuilder, so it is immutable. You'd need:
strSource = strSource.Append( "something" );
But you should certianly use a StringBuilder for work like this.
September 8, 2005 at 1:59 pm
Thanks Robert.
Yes I understand what you say.I tried many ways but did not get the output the way I wanted.
At last I could find a way to append the string values using stringbuilder without messing up with rows in data table.Previously I was using stringbuilder to append the values of string while looping for each row in data table,which did not help.Now I got the output the way I wanted.
Thanks for your time and suggestion,
Alice.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy