for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string AudioName = ds.Tables[0].Rows[i][0].ToString();
string Name = AudioName;
Name = Regex.Replace(Name, "Audio/", "");
check the number of rows count in ds.Tables[0].Rows.Count. if count is 1 then you have to check the code where you are filling the table or your sql query/SP by which you are filling the datatabe. or there might be change you have only one
record in the database table to check it .
If this post answered your question or solved your problem, please Mark it as Answer.
You need to move this line: lblaudio.Text = sb.ToString(); to be OUTSIDE the loop. Otherwise you're overwriting the label value on every iteration. [edit] actually no, it should work, though it's not efficient.
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= ds.Tables[0].Rows.Count; i++) // Less then or Equal to.
{
string AudioName = ds.Tables[0].Rows[i][0].ToString();
string Name = AudioName;
Name = Regex.Replace(Name, "Audio/", "");
sb.Append(Name + "<audio controls='controls'><source src='" + AudioName + "' type='audio/ogg'/><br/>");
lblaudio.Text = sb.ToString();
}
I'll also prefer you to use GridView. easy to use..
Good Luck`
Sincerely,
Mahad Bin Mukhtar Remember to Mark the replies as Answers
The easiest day was 'yesterday'.
MCP, MCSD
For .NET TECH Blog
Marked as answer by Mark - MSFT on Sep 17, 2012 01:23 AM
keerthijagin...
Member
138 Points
139 Posts
how to pass string builder items to lable
Sep 08, 2012 08:06 AM|LINK
Hi everybody,
I want to pass string builder items to lable
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string AudioName = ds.Tables[0].Rows[i][0].ToString();
string Name = AudioName;
Name = Regex.Replace(Name, "Audio/", "");
sb.Append(Name + "<audio controls='controls'><source src='" + AudioName + "' type='audio/ogg'/><br/>");
lblaudio.Text = sb.ToString();
}
in my database count is 2 but when i execute the code its showing only first record remaining record not binding to the lable
can any one please send the code.
Thanks in advance.
Ramesh Chand...
Star
12922 Points
2672 Posts
Re: how to pass string builder items to lable
Sep 08, 2012 08:15 AM|LINK
check the number of rows count in ds.Tables[0].Rows.Count. if count is 1 then you have to check the code where you are filling the table or your sql query/SP by which you are filling the datatabe. or there might be change you have only one record in the database table to check it .
shivanand G ...
Participant
1763 Points
534 Posts
Re: how to pass string builder items to lable
Sep 08, 2012 10:19 AM|LINK
U can also use + and && to append a string;
string StrAppend="My name: "+
"keerathi"+
"jagini";
labelid.text=StrAppend;
Thanks.
shivanand.G.N (shivu.betta@gmail.com)
MetalAsp.Net
All-Star
112241 Points
18268 Posts
Moderator
Re: how to pass string builder items to lable
Sep 08, 2012 11:01 AM|LINK
MahadTECH
Star
8976 Points
1659 Posts
Re: how to pass string builder items to lable
Sep 09, 2012 01:41 AM|LINK
it sould work..
StringBuilder sb = new StringBuilder(); for (int i = 0; i <= ds.Tables[0].Rows.Count; i++) // Less then or Equal to. { string AudioName = ds.Tables[0].Rows[i][0].ToString(); string Name = AudioName; Name = Regex.Replace(Name, "Audio/", ""); sb.Append(Name + "<audio controls='controls'><source src='" + AudioName + "' type='audio/ogg'/><br/>"); lblaudio.Text = sb.ToString(); }I'll also prefer you to use GridView. easy to use..
Good Luck`
Mahad Bin Mukhtar
Remember to Mark the replies as Answers
The easiest day was 'yesterday'.
MCP, MCSD
For .NET TECH Blog