C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Spiltting values that is inserted in table with commas


Posted Date: 08 Aug 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: Sadhana SinghMember Level: Gold    
Rating: Points: 10



For splitting values that is inserted with commas in table as for example mango,banana,apple etc

dataset ds100 = quicksearch.select_product_type();
if (ds100.Tables[0].Rows.Count != 0)
{
for (int k = 0; k <= ds100.Tables[0].Rows.Count - 1; k++)
{
example = Convert.ToString(ds100.Tables[0].Rows[k]["product_type"].ToString());
//product type field name//////////////
int z = Convert.ToInt32(ds100.Tables[0].Rows[k]["company_id"].ToString());
string[] me = example.Split(',');
int i;
for (i = 0; i <= me.Length - 1; i++)
{
Label3.Visible = false;
try
{
if (me[i] == DropDownList7.SelectedItem.Text)
{
try
{
quicksearch.get_company_id = z;
ds = quicksearch.companysearch();
if (ds.Tables[0].Rows.Count != 0)
{
//creating grid view in runtime
Label3.Visible = false;
GridView dg = new GridView();
dg.AllowPaging = true;
dg.PageSize = 50;
dg.Width = 50;
dg.Height = 50;
dg.DataSource = ds;
dg.DataBind();

Panel5.Visible = true;
Panel5.Controls.Add(dg);
flag = 1;
}
else
{
// Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('No Data Found')</script>");
Panel5.Visible = false;
}
}
catch (Exception ex)
{ }
}
else
{
}
}

catch (Exception ex)
{
// Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('No Data Found')</script>");
}
}
if (flag==0)
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('No Data Found')</script>");

Panel5.Visible = false;
}
PagedDataSource page = new PagedDataSource();
page.AllowPaging = true;
}
}
else
{
// Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('No Data Found')</script>");
}
if (flag == 0)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('No Data Found')</script>");

Panel5.Visible = false;
}





Responses

Author: Deepak S    14 Aug 2008Member Level: Gold   Points : 2
Hai,
U can also use dis for splitting

For examples we have ID's separated by commas & want the names.
We can use as:

string _AllIDS = string.Empty;
_AllIDS = _dtSent.Rows[0]["SendTo"].ToString();
string[] _NameArray = _AllIDS.Split(',');
for (int i = 0; i < _NameArray.Length; i++)
{
int _ID = Convert.ToInt32(_NameArray[i].ToString());
GetFullName(_ID);
string _AllNames = hfFullName.Value.ToString();
lblFrom.Text = _AllNames.TrimEnd(',', ' ');
}


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: List box
Previous Resource: Two buttons on home page
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use