<asp:TemplateField HeaderText="是否空闲">
<ItemTemplate>
<asp:HiddenField ID="hidKongXian" Value='<%#Eval("是否空闲")%>' runat="server" />
<asp:DropDownList ID="ddlKongXian" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlKongXian_SelectedIndexChanged">
<asp:ListItem Text="--选择--" Value="-1"></asp:ListItem>
<asp:ListItem Text="在用" Value="在用"></asp:ListItem>
<asp:ListItem Text="空闲" Value="空闲"></asp:ListItem>
<asp:ListItem Text="不确定" Value="不确定"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
<ItemStyle Width="300px" />
</asp:TemplateField>
//是否空闲
protected void ddlKongXian_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddlKongXian = sender as DropDownList;
TableCell cell = (TableCell)ddlKongXian.Parent;
GridViewRow item = (GridViewRow)cell.Parent;
string id = item.Cells[1].Text;
string kongXian = ddlKongXian.SelectedValue;
string sqlStr = "update myTable set 是否空闲='" + kongXian + "' where id=" + id;
sqlHelp.inUpDelInfo(sqlStr);
this.BindData();
}