Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
C#
string firstColumn = txtproject.Text;
            string secondColumn = txtcode.Text;
            string[] row = { firstColumn, secondColumn };
            dataGridView1.Rows.Add(row);

After I inserted this code for add button it won't show in data grid view ...... can some one give me help ?
Posted
Updated 7-Jan-14 22:31pm
v2
Comments
ravikiran from Hyderabad 8-Jan-14 1:55am    
where you wrote this..

In Page_Init

or else..
Asa code 8-Jan-14 2:05am    
in windows form inside in add button

C#
int i = dataGridView1.Rows.Add();
dataGridView1.Rows[i].Cells[0].Value = txtproject.Text;
dataGridView1.Rows[i].Cells[1].Value = txtcode.Text;
 
Share this answer
 
C#
this code will working correctly...u should wrote that inside button click event...I have checked it..
 
Share this answer
 
v2
Comments
Asa code 8-Jan-14 2:38am    
private void btnadd_Click(object sender, EventArgs e)
{

string firstColumn = txtproject.Text;
string secondColumn = txtcode.Text;
string[] row = { firstColumn, secondColumn };
dataGridView1.Rows.Add(row);


}
still it's not visible when I am running the form
it's adding the rows but not showing the text boxes typed values.... :(
Suk@nta 10-Jan-14 0:03am    
I have wrote the below code but its adding the textbox data in a row
you needs to try it in another webform.

private void button1_Click(object sender, EventArgs e)
{
string x = textBox1.Text;
string y = textBox2.Text;
string[] xc = {x,y};
dataGridView1.Rows.Add(xc);
}
Asa code 8-Jan-14 3:02am    
in additionally what should I code in here
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{

}
Suk@nta 10-Jan-14 0:13am    
can explain me what is ur requirement ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900