Hi i am using a data grid to view information now i want to select the current row that is displaying the data and just populate one text box or numericupdown with a value
the datagrid displays 3 columns that is: Invoicenumber, amount and balance now i want to load the amount in a textbox or numericupdown

can someone please help struggeling for 2 hour now please
tanx

This will do the trick:
Just for into: number 1 in the square brackets represents 2dn column in dgv.

private void GetValueFromDGVToTextBox()
        {
            int row = this.dataGridView1.CurrentCell.RowIndex;
            if (row > -1)
            {
                string value = this.dataGridView1[1, row].FormattedValue.ToString();
                textBox1.Text = value;
            }
        }

tanx will this also work if i am selecting the current row on the grid cause i need it to fill the numericupdown with the amount as soon as the row is clicked in the datagrid

Hi

This code is helpful to you to display data from data gridview to textbox.

1.
Dim t As TextBox = DirectCast(Me.GridView1.Rows(0).Cells(1).FindControl("TextBox1"), TextBox)
2.
Me.Label1.Text = "This is the TextBox text in the GridView: " & t.Text

crishjeny:
Wound you please stop posting NON-C# code in C# forum!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.