Click to See Complete Forum and Search --> : datagrid pass to database
basti42
Aug 4th, 2007, 02:30 AM
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
nmadd
Aug 4th, 2007, 09:10 AM
this.dataGridView1.Rows[0].Cells[0].Value = this.textBox1.Text;
As far as saving to the database, these will help you get started:
http://msdn2.microsoft.com/en-us/library/ms186197(VS.80).aspx
(in VB but very good) http://vbforums.com/showthread.php?t=469872
Good luck.
basti42
Aug 5th, 2007, 07:50 PM
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
nmadd
Aug 5th, 2007, 09:58 PM
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?
basti42
Aug 5th, 2007, 10:21 PM
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
basti42
Aug 5th, 2007, 10:26 PM
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?
RaviIntegra
Aug 6th, 2007, 11:23 PM
DataGridView1.Rows(0).Cells(0).Value=text1.text
DataGridView1.Rows(1).Cells(0).Value=text2.text
This will work fine
basti42
Aug 7th, 2007, 12:16 AM
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");
}
above code will send to the datagridview all inputed data?
but how can i get all data in the datagrid now?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.