I am developing one asp.net application. I have one multiselect dropdownlistbox. I have implemented this using jquery choosen pluging. User can select more than one value from dropdownbox at a time. I have one gridview below to dropdownlistbox. Logic here is values i binded to dropdownbox is equal to one of the column of gridview. This is my dropdownlistbox.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="false"
CssClass="limitedNumbSelect2" Multiple="True" >
<asp:ListItem Text="Select Gender" Value="0"></asp:ListItem>
<asp:ListItem Text="Niranjan" Value="1"></asp:ListItem>
<asp:ListItem Text="balaji" Value="2"></asp:ListItem>
<asp:ListItem Text="Neenu" Value="3"></asp:ListItem>
<asp:ListItem Text="Lindhana" Value="4"></asp:ListItem>
</asp:DropDownList>
This is my code to select multiple values from dropdownlistbox.
$(document).ready(function () {
$(".limitedNumbSelect2").chosen({
placeholder_text_multiple: "Please select Names here"
})
});
This is my clientside gridview code.
<asp:GridView ID="GridView1" runat="server" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkRow" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
<asp:TemplateField HeaderText="Country" ItemStyle-Width="150">
<ItemTemplate>
<asp:Label ID="lblCountry" runat="server" Text='<%# Eval("Country") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
This is my server side code to populate gridview.
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Name"), new DataColumn("Country") });
dt.Rows.Add("Niranjan", "Canada");
dt.Rows.Add("balaji", "United States");
dt.Rows.Add("Neenu", "China");
dt.Rows.Add("Lindhana", "India");
GridView1.DataSource = dt;
GridView1.DataBind();
}
Using jquery I want to disable the checkboxes of gridview. This is the below code for disable checkbox.
$(function () {
$('.limitedNumbSelect2').change(function (e) {
var selected = '';
selected = $("#DropDownList1 option:selected").text();
disableUsers(selected);
});
});
function disableUsers(selected)
{
temp = selected.split(",");
$.each(temp, function (index, value) {
});
}
Whenever i select Niranjan from dropdownlistbox I want to disable checkbox of corresponding row from gridview. I want to disable row of the gridview. May i get some help on this. Thank you all.
Aucun commentaire:
Enregistrer un commentaire