How to create a reusable grid view component like

2019-09-06 01:01发布

问题:

I want to create a reusable user control which contains a date time picker in asp.net. Need to add this user control in a grid view as column.While clicking the column,date time picker has to be displayed.Which is the suitable method,Creating the component or creating the user control.Also want to know,How to add this component in to the toolbox?

回答1:

The main difference between a component and a control is that a component has no UI... so clearly it is a control that you want as there must be a user interface portion for a date picker.

As for getting your control into the toolbox, right click it and there is an option to add item(s) which presents a browse dialog allowing you to locate the assembly containing your control.



回答2:

You can drag and drop UserControls without them being in the tool box. When you're in design mode for an .aspx or .ascx page, you can drag and drop the UserControl from the Solution Explorer (by just selecting the file and dragging it).