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
baskaran chellasamy
NA
114
151k
Error in datagridview
Nov 8 2012 4:11 AM
Hi friends The below code is for binding datasource to datagridview for three radiobutton checked event.
private void button6_Click(object sender, EventArgs e)
{
sdt.ACADAMICYEAR = textBox4.Text;
sdt.CLASSID = Convert.ToInt32(comboBox1.SelectedValue.ToString());
if (radioButton1.Checked == true)
{
DataTable studentbind = ibl4.studentbindforfemale(sdt);
int rowcount = studentbind.Rows.Count;
List no = ibl4.setnoofint(rowcount);
int registerno = ibl4.getregiter(sdt);
dataGridView1.DataSource = studentbind;
DataGridViewTextBoxColumn fourthcolumn = new DataGridViewTextBoxColumn(); fourthcolumn.HeaderText = "RegNo";
fourthcolumn.Name = "RegNo";
dataGridView1.Columns.Add(fourthcolumn);
for (int i = 0; i < rowcount; i++)
{
dataGridView1.Rows[i].Cells[3].Value = registerno;
}
DataGridViewComboBoxColumn fifthcolumn=new DataGridViewComboBoxColumn(); fifthcolumn.HeaderText="RegNo";
fifthcolumn.Name="RegNo";
dataGridView1.Columns.Add(fifthcolumn);
for (int i = 0; i < rowcount; i++)
{
fifthcolumn.DataSource = no;
}
}
if (radioButton2.Checked == true)
{ dataGridView
1.Rows.Clear(); dataGridView1.Refresh();
DataTable studentbind = ibl4.studentbindformale(sdt);
int rowcount = studentbind.Rows.Count;
List no = ibl4.setnoofint(rowcount);
int registerno = ibl4.getregiter(sdt);
dataGridView1.DataSource = studentbind;
DataGridViewTextBoxColumn fourthcolumn = new DataGridViewTextBoxColumn(); fourthcolumn.HeaderText = "RegNo";
fourthcolumn.Name = "RegNo";
dataGridView1.Columns.Add(fourthcolumn);
for (int i = 0; i < rowcount; i++)
{
dataGridView1.Rows[i].Cells[3].Value = registerno;
}
DataGridViewComboBoxColumn fifthcolumn = new DataGridViewComboBoxColumn(); fifthcolumn.HeaderText = "RegNo";
fifthcolumn.Name = "RegNo";
dataGridView1.Columns.Add(fifthcolumn);
for (int i = 0; i < rowcount; i++)
{
fifthcolumn.DataSource = no;
}
}
if (radioButton3.Checked == true)
{
dataGridView1.Rows.Clear();
dataGridView1.Refresh();
DataTable studentbind = ibl4.studentbindforgeneral(sdt);
int rowcount = studentbind.Rows.Count;
List no = ibl4.setnoofint(rowcount);
int registerno = ibl4.getregiter(sdt);
dataGridView1.DataSource = studentbind;
DataGridViewTextBoxColumn fourthcolumn = new DataGridViewTextBoxColumn(); fourthcolumn.HeaderText = "RegNo";
fourthcolumn.Name = "RegNo";
dataGridView1.Columns.Add(fourthcolumn);
for (int i = 0; i < rowcount; i++)
{
dataGridView1.Rows[i].Cells[3].Value = registerno;
}
DataGridViewComboBoxColumn fifthcolumn = new DataGridViewComboBoxColumn(); fifthcolumn.HeaderText = "RegNo";
fifthcolumn.Name = "RegNo";
dataGridView1.Columns.Add(fifthcolumn);
for (int i = 0; i < rowcount; i++)
{
fifthcolumn.DataSource = no;
}
}
}
when i click signle radiobutton(any of three) for button event, it gives a expected result.but if i click the second radiobutton and it does add the result to already datagridvalue. for clearing datagridview i use datagridview.rows.clear(). but it raise an error as " Collapse | Copy Code Cannot clear the list ". i want to display the appropriate value for appropriate radiobutton click event. please find solve my problem. Thank you
Reply
Answers (
1
)
how to display gridview cells data in a pop up when i will click the cell ? in java script how it is solve ?in asp.net with c# with example?
how to set gridview cells color as red if the cells data are not present in the database table,and set blue if data are present ,and black as holiday in asp.net?