|
-
October 17th, 2002, 08:59 AM
#1
datagrid databind implementation
I was wondering if anyone could shed some light on exactly how the datagrid binds to a datatable.
I know for instance that the datagrid will bind to public properties of an object (and not public fields for some reason). And I know that ITypedList plays some role when a datagrid binds to a table. But how does the datagrid know how to extract the field values from a tablerow??
I've tried using indexers in my own objects to facilitate a binding but the datagrid seems to ignore it.
Is there some other interface that the datatable is implementing which allows the datagrid to retrieve its fields by name?
I can't seem to find anything about it on msdn. Any help would be greatly appreciated!
-
January 21st, 2003, 07:46 PM
#2
Hi,
Pls see this and it will explain :
'Binding data source to datagrid
DataGrid1.DataSource = ds
DataGrid1.DataMember = "Users"
DataGrid1.DataBind()
You have to cast the item in tablerows into TextBox like this inorder to access to it's value:
Dim unameText As TextBox = CType(e.Item.Cells(1).Controls(0), TextBox)
Dim uidText As TextBox = CType(e.Item.Cells(0).Controls(0), TextBox)
Dim dateText As TextBox = CType(e.Item.Cells(2).Controls(0), TextBox)
Dim empnumText As TextBox = CType(e.Item.Cells(3).Controls(0), TextBox)
Dim upassText As TextBox = CType(e.Item.Cells(4).Controls(0), TextBox)
par1 = uidText.Text
par2 = unameText.Text
par3 = dateText.Text
par4 = empnumText.Text
par5 = upassText.Text
Hope this help,
rgds
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
|