Dropdownlist with GridView in Visual Studio

Dropdownlist with gridview

 

1.open visual developer and click open a new website.

 

2.create two tables

 a. category      fields – categoryid-int,name-varchar

 b. product       fields – poductid-int,name-varchar,price-double,category-varchar

 

3. drag asqdatasource from toolbo .

   Click topright corner-add new datasource .in data connection-click and select  connectionstring and click net  select category table from dropdown and select all fields.

And finish.

 

4.drag dropdownlist from toolbo  and click righttop corner and choose datasource.

In that select datasource-sqldatasource1

Datafield to display –category

Datafield value – categoryid

Click ok

Now click top right corner of dropdownlist click autopostback .

 

5.now drag another sqldatasource and add new datasource ,data connection –connection string  then select product table from dropdown . select all fields and click where condition.

Condition column-categoryid

Operator   =

Source  - control

Controlid  - dropdown

 

Click add and ok

 

6. drag a gridview and add datasource –sqldatasource2

 

Now press f5 and run.

 

7. To make the grid colorful right click top corner of grid and select autoformat. In that select colorful And click ok.

8. To remove any fields in the grid,  right click top corner of grid and select edit columns and delete  the required field

9. To add new columns ,right click top corner of grid and select add columns

Choose field type –hyperlink

Header tet-Details

Specifytet-details

Get detail from url: authored

url format string-  detail.asp?authorid={0}

click ok.

 

10. Likwise you can do enable page sorting,enable paging.

 

Note: if you change grid properties then you can do edit update in grid

Asif-dharapuram

 

.

  

 

 

Add new comment