473,378 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Searching Multiple rows in datagridview through button click

private void button1_Click(object sender, EventArgs e)
{
//
DataGridView dgview = new DataGridView();
//dataGridView1.RowCount=0;
try
{
for (int row = 0; row < dataGridView1.RowCount - 1; row++)
{

// dataGridView1.MultiSelect = false;

if (dataGridView1.Rows[row].Cells["Model"].Value.ToString().Substring(0,textBox1.Text.Length ) == textBox1.Text)
{
dataGridView1.Rows[row].Selected = true;
dataGridView1.Rows[row].Cells["column1"].Value = true;
// MessageBox.Show("data has been selected");
}
else
{
MessageBox.Show("data not found");
}
}
}
catch (Exception Error)
{
//MessageBox.Show("data not selected");
MessageBox.Show(Error.ToString());
}


}
i have above code ........... when i perform it shows exception has "index and length must refer to the same location within the string" i'm not getting what to do .... fresher to this application ........pls help me
Jan 5 '12 #1
0 1191

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: David | last post by:
I was looking at this article, but it doesn't work for me. http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.multiselect.aspx I can not select multiple rows in my...
3
by: manjub | last post by:
Hi, I am trying to add ability to delete multiple rows from a DataGridView in my application. When user selects multiple rows and presses delete button, I want to show a message asking to user...
2
by: beish1 | last post by:
Hi I have a page which displays a Gridview containing on each row a checkbox and 3 fields/cells (title, longitude, latitude). On the same page I have two textboxes containing the latitude and...
6
by: =?Utf-8?B?TU1TSkVE?= | last post by:
How to let user delete multi rows from the BindingSource while the SelectionMode Property set to RowHeaderSelect I have in my program datagridview bound it to sql table Throw Bindingsource To...
3
by: =?Utf-8?B?S2F5xLFoYW4=?= | last post by:
In my project,i added datagridview to my form , i transfered my table to datagridview and added multiple rows and when i called dataadapther.update ,,result is ok. But when i tried it for the...
3
by: nigelesquire | last post by:
Please help! I'm trying to clone and delete multiple rows with JavaScript. I need two delete buttons that work...! I only have one for now, but it's not working properly, the output count is...
0
by: bplthebest | last post by:
Hi I have have functionality like Selecting multiple rows (without using check boxes) in Grid view by Ctrl+click (IE) and shift+click(safari and Firefox). And edit the selected rows in a panel...
6
by: Gun Slinger | last post by:
Hi guys, I have a quick question which i have pondered for a little while. I'm not sure if its even a good idea (so maybe advice on whether or not to do it would be helpful as well). I want to...
1
by: yogarajan | last post by:
Hi Friend this is my code protected void Page_Load(object sender, EventArgs e) { for (int i = 0; i < 10; i++) { TableRow tr = new TableRow();
1
by: su817200 | last post by:
Dear Friend, I would like to run multiple functions on Button Click eg... <input type="button" value="Update" name="B1" onclick="ReadFileToString() timedRefresh(1500)"></p> It is giving...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.