|
-
Aug 4th, 2007, 02:30 AM
#1
Thread Starter
Hyperactive Member
datagrid pass to database
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
*****************
VB6,PHP,VS 2005
-
Aug 4th, 2007, 09:10 AM
#2
Re: datagrid pass to database
Code:
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/lib...97(VS.80).aspx
(in VB but very good) http://vbforums.com/showthread.php?t=469872
Good luck.
-
Aug 5th, 2007, 07:50 PM
#3
Thread Starter
Hyperactive Member
Re: datagrid pass to database
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
*****************
VB6,PHP,VS 2005
-
Aug 5th, 2007, 09:58 PM
#4
Re: datagrid pass to database
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?
-
Aug 5th, 2007, 10:21 PM
#5
Thread Starter
Hyperactive Member
Re: datagrid pass to database
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
*****************
VB6,PHP,VS 2005
-
Aug 5th, 2007, 10:26 PM
#6
Thread Starter
Hyperactive Member
Re: datagrid pass to database
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?
*****************
VB6,PHP,VS 2005
-
Aug 6th, 2007, 11:23 PM
#7
Registered User
Re: datagrid pass to database
vb Code:
DataGridView1.Rows(0).Cells(0).Value=text1.text
DataGridView1.Rows(1).Cells(0).Value=text2.text
This will work fine
-
Aug 7th, 2007, 12:16 AM
#8
Thread Starter
Hyperactive Member
Re: datagrid pass to database
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");
}
above code will send to the datagridview all inputed data?
but how can i get all data in the datagrid now?
*****************
VB6,PHP,VS 2005
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|