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
Gopal Ji Singh
NA
39
31.7k
Error : Index was outside the bounds of the array
May 2 2014 2:28 AM
Hi
There is a problem in my code and i am not aware how to resolve this .
My Error is
Index was outside the bounds of the array
. when i am passing 1 or 2 value in textbox it gives error and when i am passing 3 or more than 3 value in textbox it is working fine so please help me and resolve my problem if anybody can .
My Code is
protected void btnsearch_Click(object sender, EventArgs e)
{
try
{
string shortWord = txtsearch.Text;
//split the text Into Seperate Words
string delimstr = ",";
char[] delimiter = delimstr.ToCharArray();
string[] ValueArray = shortWord.Split(delimiter);
SqlCommand cmd = new SqlCommand("select * from Rgisterbasic where name like '%" + ValueArray[0].Trim() + "%' and city like '%" + ValueArray[1].Trim() + "%' and email like '%" + ValueArray[2].Trim() + "%'", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
Thanks
Gopal
Reply
Answers (
5
)
Datatable with check boxes for multi row deletion ?mvc4
data insert in text change event