Monday, April 05, 2010

How to Add Dropdown List in Gridview

I saw it been done before but never got about doing it. Here is the site with the Text guide on how to easily do it, almost 95% using UI only, NO CODES Needed! *COOL*

http://msdn.microsoft.com/en-us/library/ms178294%28VS.80%29.aspx

In Short here are the steps:-
  1. Right-click the GridView control and select Show Smart Tag. In the GridView Tasks menu, select Edit Columns.

  2. In the Fields dialog box, select yourField from the Selected fields list box.

  3. Click Convert this field into a TemplateField link.

  4. Click OK to close the Fields dialog box.

  5. Right-click the GridView control and select Show Smart Tag. In the GridView Tasks menu, select Edit Templates.

  6. Select EditItemTemplate in the Display drop-down list.

  7. Right-click the default TextBox control in the template and select Delete to remove it.

  8. From the Standard tab of the Toolbox, drag a DropDownList control onto the template.

  9. Right-click the DropDownList control and select Show Smart Tag. In the DropDownList Tasks menu, select ChooseData Source.

  10. Select SqlDataSource2 (if your dropdown list data source is from there) or you can easily enter in values via the drop downlist data wizard.

  11. Click OK.

  12. In the DropDownList Tasks menu, choose Edit DataBindings. The SelectedValue property of the DropDownList control is selected in the DataBindings dialog box.

  13. Click the Field Binding radio button and select youtField for Bound To.

  14. Select the Two-way databinding check box.

  15. Click OK.

  16. Right-click the GridView control and select Show Smart Tag. In the GridView Tasks menu, click End Template Editing.



No comments: