对DropDownList更改执行更新



目前,我在ItemTemplate中有一个GridView,其中包含以下内容:

<asp:LinkButton ID="lbEdit" runat="server" CommandName="Edit">
    <asp:Label ID="Label6x" runat="server" Text='<%# Bind("progress_full") %>' /></asp:LinkButton>

这很好,当我点击它时,它会显示当前包含以下内容的EditTemplate:

<asp:DropDownList ID="DropDownList3" runat="server" 
    SelectedValue='<%# Bind("progress") %>'>
    <asp:ListItem Value="0">In queue</asp:ListItem>
    <asp:ListItem Value="1">Being worked on</asp:ListItem>
    <asp:ListItem Value="2">Complete</asp:ListItem>
</asp:DropDownList><br />
<asp:LinkButton ID="lbUpdate" runat="server" CommandName="Update" Text="Update" />

如何使下拉列表在更改时自动执行Update命令,立即返回到ItemTemplate,而不是更改下拉列表并单击Update

AutoPostBack="true"添加到DropDownList并设置OnSelecIndexChanged="DropDownList1_SelectedIndexChanged"

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
   //execute here your update
   ......
}

最新更新