There is a way, but its a little complicated.
You can work with the ItemDataBound event of the datagrid to manipulate each row of a datagrid as it's bound. In this method, you can access "e" which is the DataGridEventArgs. Off that is "Item" which is a DataGridItem. On it is the "Cells" collection, then off one item of that collection ("Cells(n)") you can access the "Controls" collection. When the datagrid draws in edit mode you will typically have a single control in the cell, this will be the textbox. Potentially, you could remove the textbox and replace it with another server control of your choosing. Then when you hit the "Update" datagrid method for that row, you'll have to dig out the value of your new server control in the same manner that you found and replaced the text box...
CType(e.Item.Cells(n).Controls(0),ControlType).ControlSpecificProperty
If your plan is to handle every column the same, then you just need to loop thru "e.Item.Cells" to modify each one.
Keep in mind that in the "DataItemBound" method, you'll need to check each item to see if it is an "EditItem" so you only modify the selected row.
Why must you use autogenerate columns? This is a bit easier with template columns.
Peter
|