Nirmal Roy

Nirmal Roy

  • NA
  • 365
  • 29.4k

Data grid Bonding Error

Aug 24 2016 2:32 AM
private void dataRepeater1_DrawItem(object sender, Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)<br /> {<br /> Label txtExample = (Label)e.DataRepeaterItem.Controls["label1"] as Label;<br /> Label label2 = (Label)e.DataRepeaterItem.Controls["label2"] as Label;<br /> Label label3 = (Label)e.DataRepeaterItem.Controls["label3"] as Label;<br /> Label label4 = (Label)e.DataRepeaterItem.Controls["label4"] as Label;<br /> var grid = e.DataRepeaterItem.Controls["dataGridView1"] as DataGridView;<br /> if (txtExample.Text != null &amp;&amp; label2.Text != null &amp;&amp; label3.Text != null &amp;&amp; label4.Text != null)<br /> {<br /> SqlDataAdapter daa = new SqlDataAdapter(@"select Question,Fullmarks from dbo.tbl_QuestionConfig where Sectiontype='" + label2.Text + "' and Questiontype='" + label3.Text + "' and Subject='" + label4.Text + "'", con);<br /> DataTable dtt = new DataTable();<br /> daa.Fill(dtt);<br /> if (dtt.Rows.Count &gt; 0)<br /> {<br /> dataGridView1.DataSource = dtt;<br /> dataGridView1.AutoGenerateColumns = false;<br /> dataGridView1.EnableHeadersVisualStyles = false;<br /> dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSeaGreen;<br /> foreach (DataGridViewRow r in dataGridView1.Rows)<br /> {<br /> r.DefaultCellStyle.BackColor = Color.LightCyan;<br /> }<br /> }<br /> }<br /><div> }</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;datagrid view&nbsp; binding&nbsp; error.</div>

Answers (2)