01/06/2025 | 03:25 AM

Biểu mẫu trường dữ liệu giới tính

Xem: 3
(LTC) Biểu mẫu trường dữ liệu giới tính
1. Thực hiện chèn
<asp:DropDownList ID="cboiGender" CssClass="dropdown" EnableViewState="false" runat="server" ValidationGroup="FormtblPhieumuon"></asp:DropDownList>

2. Sử dụng hàm bind dữ liệu
private void BindGioitinh()
{
    try
{
cboiGender.Items.Clear();
        string[] arrName = new string[] { "Không xác định", "Nam giới", "Nữ giới" };
        int i = 0;
        for(i = 0; i < arrName.Length; i++)
{
cboiGender.Items.Add
(
new ListItem
(
                    arrName[i],
i.ToString()
)
);
}
        cboiGender.SelectedValue = "0";
}
catch { }
}

3. Thiết lập tùy chọn lựa chọn
cboiGender.SelectedValue = entity.iGender.ToString();

4. Nhận dữ liệu
entity.iGender = Convert.ToInt32(cboiGender.SelectedValue);
Xem: 3

Các bài viết khác

Loading ...