i want to pass the value of the textboxes first in datagrid then save it to the database...
e.g.
text1.text = value1
text2.text = value2
how would i do that?
ask if its not clear... tnx
Printable View
i want to pass the value of the textboxes first in datagrid then save it to the database...
e.g.
text1.text = value1
text2.text = value2
how would i do that?
ask if its not clear... tnx
As far as saving to the database, these will help you get started:Code:this.dataGridView1.Rows[0].Cells[0].Value = this.textBox1.Text;
http://msdn2.microsoft.com/en-us/lib...97(VS.80).aspx
(in VB but very good) http://vbforums.com/showthread.php?t=469872
Good luck.
i tried above but it has error like below,
"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
sorry i'm not familiar could you please give me more examples?
tnx
The example above refers to the first cell in the first row of the DataGridView. It seems you do not have any cells in your DataGridView?
Can you also confirm that you are using a DataGridView and not a DataGrid?
i am using datagridview, all inputed in the 2 textboxes after the button clicked
the text in the 2text boxes will send to the datagridview
text1.text= sample1
text2.text= sample2
column1 column2
sample1 sample2
i am using datagridview, all inputed in the 2 textboxes after the button clicked
the text in the 2text boxes will send to the datagridview
text1.text= sample1
text2.text= sample2
datagridview:
column1 column2
sample1 sample2
and how would i get all data in the datagridview?
vb Code:
DataGridView1.Rows(0).Cells(0).Value=text1.text DataGridView1.Rows(1).Cells(0).Value=text2.text
This will work fine
above code will send to the datagridview all inputed data?Code:private void button1_Click(object sender, EventArgs e)
{
string[] DataResult1 = { textBox1.Text, textBox2.Text};
dataGridView1.Rows.Add(DataResult1);
}
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.Columns.Add("colName", "Name");
dataGridView1.Columns.Add("colSurName", "Last Name");
}
but how can i get all data in the datagrid now?