日期:2014-05-17 浏览次数:20577 次
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string sql = "select * from EP_TblMailbox where SendToDepartment = '维修部'";
SqlDataReader sdr = dataOperate.getRow(sql);
sdr.Read();
if (sdr["IsVisted"].ToString() =="true")
{
DropDownList ddl = (DropDownList)e.Row.Cells[0].FindControl("DropDownList2");
ddl.SelectedValue = "是";
}
if (sdr["IsVisted"].ToString() == "false")
{
DropDownList ddl = (DropDownList)e.Row.Cells[0].FindControl("DropDownList2");
ddl.SelectedValue="否";
}
}
}
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="ID" HeaderText="编号" />
<asp:BoundField DataField="SenderName" HeaderText="发送人" />
&nb