0

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

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by Mitja Bonca
0

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;
            }
        }
0

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

0

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

Edited by __avd: Remove links

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.