displaying in a text box

Can anyone give me some advice on displaying a certain field in a textbox? I have a datagrid that has customers and in the textbox I need to display their order count in. I can display it by clicking the plus sign next to the record.... Please help!!

Comments

: Can anyone give me some advice on displaying a certain field in a textbox? I have a datagrid that has customers and in the textbox I need to display their order count in. I can display it by clicking the plus sign next to the record.... Please help!!: :

Well,what do you mean by "order count"?If it's just the number of rows in your table you can get it using RecordCount property:[code]TextBox1.Text=CStr(ADO.Recordset.RecordCount)[/code]

I know that I need to use the datagrid_currentcellchanged formula to make it work, but I don't how.... But I did need to know how to do the recordcount as well so thanks!!

: : Can anyone give me some advice on displaying a certain field in a textbox? I have a datagrid that has customers and in the textbox I need to display their order count in. I can display it by clicking the plus sign next to the record.... Please help!!: : : : : : Well,what do you mean by "order count"?: If it's just the number of rows in your table you can get it using RecordCount property:: [code]: TextBox1.Text=CStr(ADO.Recordset.RecordCount): [/code]:

[b][red]This message was edited by Moderator at 2005-7-27 10:32:49[/red][/b][hr][b][red]This message was edited by Moderator at 2005-7-27 10:31:45[/red][/b][hr]: It isn't the number of rows, it is a field in a sub-table that was created by writing a select statement in the DataAdapter...: : SELECT: COUNT(customerid) AS OrderCount, : CustomerID: FROM: Orders: GROUP BY: CustomerID: : I know that I need to use the datagrid_currentcellchanged formula to make it work, but I don't how.... But I did need to know how to do the recordcount as well so thanks!!: : : : Can anyone give me some advice on displaying a certain field in a textbox? I have a datagrid that has customers and in the textbox I need to display their order count in. I can display it by clicking the plus sign next to the record.... Please help!!: : : : : : : : : : Well,what do you mean by "order count"?: : If it's just the number of rows in your table you can get it using RecordCount property:: : [code]: : TextBox1.Text=CStr(ADO.Recordset.RecordCount): : [/code]: : : :

Hi,

I didn't know you are using VB.NET.Because of it,you won't be able to use Recordset.RecordCount.Instead of it,use this code:[code]TextBox1.Text=DataSet1.Tables("NameOfYourTable").Rows.Count.ToString[/code]

And about getting the selected row..I think you should use a code like this:

[code] 'Put this in global scope (on top of your form code): Public old_row As Integer = -1

'The following sub will get the selected row if user makes any changes to the DataSource (i.e. deletes the record): Private Sub DataGrid1_DataSourceChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridInst.DataSourceChanged GridInst_CurrentCellChanged(Nothing, Nothing)