TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
harshada dumbhare
NA
2
3.3k
how to display code which not present in datable
Feb 15 2013 2:33 AM
Hello sir,
In my website I have to search verious varinateno.
I have taken one textbox. there if will insert varinatenos line by line it should dislplay Image and ditail of varinatnos which are present in database and in one lable it should display varinatnos which are not present in datatable.
Here how to dispaly varinatnos in lable which are not in datatable.
following is the code.
protected void btnSearch_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "" && TextBox1.Text != null)
{
string[] VarinateNo = TextBox1.Text.Split('\n');
string search = String.Empty;
foreach (string v in VarinateNo)
{
search += "'" + v + "',";
//strMyString = strMyString.Replace("\r\n", "_");
search = search.Replace("\r", string.Empty);
}
search = search.Trim(',');
con.Open();
SqlCommand cmd = new SqlCommand("Select VarinatNo,Ucp,ImageName From TitanMaster where VarinatNo in (" + search + ")", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = new DataTable();
da.Fill(dt);
dlViewAllWatches.DataSource = ds;
dlViewAllWatches.DataBind();
if (dt.Rows.Count == 0)
{
Label1.Text = "NO RESULT FOUND";
}
else
{
char[] separator = new char[] { ',' };
string[] strSplitArr = search.Split(separator);
string Varinate = String.Empty;
foreach (string v in strSplitArr)
{
foreach (DataRow dr in dt.Rows)
{
if (v == "'" + dr["VarinatNo"].ToString() + "'")
{
break;
}
else if (v != "'" + dr["VarinatNo"].ToString() + "'")
{
}
else
{
Varinate += v;
}
}
}
Label3.Text = Varinate;
Label1.Text = "SEARCH RESULT : WE HAVE FOUND " + (dt.Rows.Count.ToString());
}
}
}
Please replay fast.
Reply
Answers (
0
)
asp.net 2.0
Required Field Validator based on condition