Dear All,
I have checkbox list binding from code behind with the years
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal"></asp:CheckBoxList>
protected void Page_Load(object sender, EventArgs e)
{
CheckBoxList1.Items.Clear();
var currentYear = DateTime.Today.Year;
for (int i = 4; i >= 0; i--)
{
// Now just add an entry that's the current year minus the counter
CheckBoxList1.Items.Add((currentYear - i).ToString());
}
}
here i am getting the error
An exception of type 'System.NullReferenceException' occurred in KPI.dll but was not handled in user code
Object reference not set to an instance of an object.
protected void Button1_Click(object sender, EventArgs e)
{
string yearly = CheckBoxList1.SelectedItem.ToString();
Response.Redirect("~/InsertDatatoKPI.aspx?userID=" + yearly);
}
Thanks