gridview中dropdownlist的赋值问题
我在gridview中的模板列放了个dropdownlist 现在想从数据库读出数据 其中一个属性值要赋值给dropdownlist 并且实现在gridview的updating时 dropdownlist 是激活的 不更新时是不激活的 求大神指导
updating事件
protected void GrvRepairMailbox_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//this.GrvRepairMailbox.Rows[e.RowIndex].Cells[7].Controls[0]
string ID = GrvRepairMailbox.DataKeys[e.RowIndex].Value.ToString();
//string IsVisted = ((TextBox)(GrvRepairMailbox.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim();
string IsVisted = ((DropDownList)(this.GrvRepairMailbox.Rows[e.RowIndex].FindControl("ddl1"))).SelectedValue.ToString().Trim();
string Isolved = ((TextBox)(GrvRepairMailbox.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString().Trim();
string udpsql = "update EP_TblMailbox set IsVisted='" + IsVisted + "', Isolved='" + Isolved + "' where ID='" + ID + "'";
dataOperate.execSQL(udpsql);
GrvRepairMailbox.EditIndex = -1;
GrvRepairMailboxbindData();
}
protected void GrvRepairMailboxbindData()
{
string sql = "select * from EP_TblMailbox where SendToDepartment = '维修部'";
GrvRepairMailbox.DataSource = dataOperate.getDataset(sql, "EP_TblRepairMailbox");
GrvRepairMailbox.DataKeyNames = new string[] { "ID" };
GrvRepairMailbox.DataBind();
}
<asp:GridView ID="GrvRepairMailbox" runat="server" AutoGenerateColumns="False"
onselectedindexchanging="GrvRepairMailbox_SelectedIndexChanging"
onrowcancelingedit="GrvRepairMailbox_RowCancelingEdit"
onrowediting="GrvRepairMailbox_RowEditing"
onrowupdating="GrvRepairMailbox_RowUpdating">
<Columns>
<asp:BoundField DataField="ID" HeaderText="编号" />
<asp:BoundField DataField="SenderName" HeaderText="发布人" />
<asp:BoundField DataField="SendDepartment" HeaderText="发布部门" />
<asp:BoundField DataField="ReportID" HeaderText="报告编号" />
<asp:BoundField DataField="Type" HeaderText="报告类型" />
<asp:BoundField DataField="IsVisted" HeaderText="已阅读" />
<asp:BoundField DataField="Isolved" HeaderText="已解决" />
<asp:TemplateField HeaderText="是否阅读">
<ItemTemplate>
<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="True">
<asp:ListItem Value="true">是</asp:ListItem>
<asp:ListItem Value="false">否</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowSelectButton="True" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>