I have a multi select dropdown containg TagID like this
now I want to update the PenID against the multi select TagID.
for example I multiselect the two TagID 102 and 103 and from the dropdown list I select the PenID SKY and perform the update operation.
Simpley, It can be said that I want to perform multiselect update on a single click rather to update one by one row. How it can be done?
my code is
<div class="row">
<div class="col-sm-12">
<label class="control-label" style="margin-top: 10px;">
Tag ID</label>
<asp:DropDownList ID="ddlTag" runat="server" class="form-control">
</asp:DropDownList>
<br/>
<asp:ListBox ID="lstTag" runat="server" SelectionMode="Multiple" class="form-control" >
</asp:ListBox>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label class="control-label" style="margin-top: 10px;">
Move To</label>
<asp:DropDownList ID="ddlPen" runat="server" class="form-control">
</asp:DropDownList>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label class="control-label" style="margin-top: 10px;">
Date</label>
<asp:TextBox ID="txtDate" runat="server" class="form-control" placeholder="Move to Pen Date"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate" PopupButtonID="txtDate" Format="dd.MM.yyyy" >
</asp:CalendarExtender>
</div>
</div>
protected void btnAdd_Click(object sender, EventArgs e)
{
// this.BindGridUpdate();
try
{
con = new SqlDbConnect();
con.SqlQuery("Update tblAnimal set PenID=@PId where TagID=@TId");
con.Cmd.Parameters.Add(new SqlParameter("@PId", this.ddlPen.SelectedValue.ToString()));
con.Cmd.Parameters.Add(new SqlParameter("@TId", this.ddlTag.SelectedValue.ToString()));
con.NonQueryEx();
con.conClose();
ClearControls(Page);
// this.BindGrid();
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Animal Moved to the Pen Successfully.');", true);
btnAdd.Visible = true;
btnUpdate.Visible = false;
btnDelete.Visible = false;
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}