Hi there,
Being a newbie to C#Net 2003, I am having problem trying to retrieve data from a specific clicked row on the DataGrid to display the data on the TextBox on the FORM. This is the structure of the DataGird:-
Col0 = CustomerId
Col1 = First Name
Col2 = Last Name
Col3 = CreditCard

Please help me. I need your help for the C# script.
The script below is not working.
private void DataGrid_Click(object Sender, System.EventArgs e)
{
int CurrRow = DataGrid.CurrentRowIndex;
txtCustID.text = DataGrid.CurrentCell(currRow,0);
txtFirstName.text = DataGrid.CurrentCell(currRow,1);
txtLastName.text = DataGrid.CurrentCell(currRow,2);
txtCreditCard.text = DataGrid.CurrentCell(currRow,3);
}

Thanks.

Please use code tags:

[code=csharp]
...code here....
[/code]

I don't think your code will compile. DataGrid.CurrentCell is a property, not a method...

Did you just copy and paste that event handler (DataGrid_Click), or did you use the designer to create it?

You can access those text values using the object you provided as the DataSource .

I did copy and paste the code. 
It encountered compilation problems as well.
Being a new to C# Net 2003, I just don't know to solve me.
Hope to receive a sample script from awesome guys like you.

hie lennie..
i have visual studio 2005 and the code works fine. not sure about visual 2003 but u can still giv it a try...

textbox1.text = dataGridView1.Rows[dataGridview1.CurrentRow].Cells[columnindex].Value.toString();

more over u r nt suppose to paste text between code tags only the code between code tags

How is your datagrid being bound? It is usually easier to work with the underlying data as opposed to the grid.

Hi All,
Thanks for your help. My script is working now.

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.