hi there,
I tried to generate tabs dynamically on a dropdownlist selectedindex change event and i am successed. But while i change the list item of the drop downlist it throws me error line the description shows below.
[
Server Error in '/' Application.
Specified argument was out of the range of valid values.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: value
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: value] AjaxControlToolkit.TabContainer.set_ActiveTabIndex(Int32 value) +461 AjaxControlToolkit.TabContainer.LoadControlState(Object savedState) +244 System.Web.UI.Control.LoadControlStateInternal(Object savedStateObj) +120 System.Web.UI.Page.LoadAllState() +353 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +741 |
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2556.0 ]
The code i am giving bellow
// Front end
<%@ Page Title="" Language="C#" MasterPageFile="~/OCPL_MAST.Master" AutoEventWireup="true" CodeBehind="Acquisition_Annihiliation.aspx.cs" Inherits="OCPL.Application.New_Land_Management.Acquisition_Annihiliation" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head_Content" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Body_Content" runat="server">
<div class="header">
<h1 class="page-title">Land Acquisition Management</h1>
<ol class="breadcrumb">
<li><a href="../DashBoard_info/DM_Dashboard.aspx">Home</a></li>
<li class="active">Land Acquisition Management</li>
</ol>
<div class="clearfix"></div>
</div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div id="page-inner">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<asp:UpdatePanel ID="upd1" runat="server">
<ContentTemplate>
<div>
<asp:Label ID="lbl1" runat="server" Text="Project:"></asp:Label>
<asp:DropDownList ID="ddlproject" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlproject_SelectedIndexChanged"></asp:DropDownList>
</div>
<div>
<asp:Label ID="lbl2" runat="server" Text="Village:"></asp:Label>
<asp:DropDownList ID="ddlvillage" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlvillage_SelectedIndexChanged"></asp:DropDownList>
</div>
<div>
<asp:Panel ID="Panel1" runat="server">
<asp:TabContainer ID="tabmenu" runat="server" OnInit="tabmenu_Init" Visible="true">
</asp:TabContainer>
</asp:Panel>
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="ddlvillage" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
</asp:Content>
// back end
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BAL;
using UtilityClass;
using System.IO;
using System.Data;
using System.Data.SqlClient;
namespace OCPL.Application.New_Land_Management
{
public partial class Acquisition_Annihiliation : System.Web.UI.Page
{
//AjaxControlToolkit.TabContainer tabmenu;
string ddlval = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
loadproject();
}
}
private void loadproject()
{
DataTable dt = new DataTable();
dt = CommonClass.ViewDataWithOutConditon("select PROJ_CODE,PROJ_NAME from PROJECT_DETAIL_MASTER");
ddlproject.DataSource = dt;
ddlproject.DataTextField = "PROJ_NAME";
ddlproject.DataValueField = "PROJ_CODE";
ddlproject.DataBind();
ddlproject.Items.Insert(0,"Select");
}
protected void ddlproject_SelectedIndexChanged(object sender, EventArgs e)
{
ddlval = ddlproject.SelectedValue;
DataTable dt = new DataTable();
dt = CommonClass.ViewDataWithOutConditon("select VILL_NAME,VILL_CODE from VILLAGE_CODE_MASTER where PROJ_CODE='"+ddlproject.SelectedValue+"'");
ddlvillage.DataSource = dt;
ddlvillage.DataTextField = "VILL_NAME";
ddlvillage.DataValueField = "VILL_CODE";
ddlvillage.DataBind();
ddlvillage.Items.Insert(0, "Select");
}
protected void ddlvillage_SelectedIndexChanged(object sender, EventArgs e)
{
tabmenu_Init(sender, e);
}
protected void tabmenu_Init(object sender, EventArgs e)
{
if (IsPostBack)
{
try
{
DataTable dt = new DataTable();
if (ddlvillage.SelectedIndex != 0)
{
dt = CommonClass.ViewDataWithOutConditon("select distinct LAC_NO from LA_CASE_WISE_LAND_SCHEDULE where PROJ_Code='" + ddlproject.SelectedValue + "' and VILL_CODE='" + ddlvillage.SelectedValue + "' and LAND_CLASS='Govt.'");
}
for (int i = 0; dt.Rows.Count - 1 >= i; i++)
{
AjaxControlToolkit.TabPanel tabpnl = new AjaxControlToolkit.TabPanel();
tabpnl.ID = "Tab1" + i.ToString();
tabpnl.HeaderText = "Tab" + dt.Rows[i]["LAC_NO"].ToString();
tabmenu.Tabs.Add(tabpnl);
Button btn = new Button();
btn.ID = "txtbx" + tabpnl.ID;
btn.Text = "hello";
tabpnl.Controls.Add(btn);
tabmenu.ActiveTabIndex = 0;
}
}
catch (Exception ep)
{
throw ep;
}
}
}
}
}
PLEASE HELP ME OUT... THANK YOU