




















































1
using System;
2
using System.Data;
3
using System.Configuration;
4
using System.Collections;
5
using System.Web;
6
using System.Web.Security;
7
using System.Web.UI;
8
using System.Web.UI.WebControls;
9
using System.Web.UI.WebControls.WebParts;
10
using System.Web.UI.HtmlControls;
11
12
public partial class GridSamples_GridView_GirdView : System.Web.UI.Page
13
{
14
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
15
{
16
if (e.Row.RowIndex > -1)
17
{
18
AccessDataSource accessDS = e.Row.FindControl("AccessDataSource2") as AccessDataSource;
19
accessDS.SelectParameters["deptid"].DefaultValue = e.Row.Cells[0].Text;
20
}
21
}
22
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

只需要上面几行简单的代码便可以实现。