DataGrid questions (urgent)

  • Thread starter Thread starter Vincent
  • Start date Start date
V

Vincent

1. In the edit mode of the datagrid, can I restrict the
max. length of data entry the editing textbox ?
eg in my database table, the length of the field is 10, I
want to make sure that user will not enter data with
length more than 10

2. I have made a template column of checkbox in
datagrid, how can I add a check all function for them ?

Thx
 
Here is the answers for your question,

1 . In editmode, set the Maxlength for the Textbox in ItemDataBound event
handler.
2. Have a button in your form. when you press that button loop throught
datagrid items and check all your check box.
 
I know how to loop through the dataGrid items, however,
how can I check the check box ?
 
check out this code snippet,

For Each di In DataGrid1.Items

' Make sure this is an item and not the header or footer.

If di.ItemType = ListItemType.Item OrElse di.ItemType =
ListItemType.AlternatingItem Then

CType(di.FindControl("chkbox1"), RadioButton).Checked = True

End If

Next
 
Back
Top