I have one problem that can not resolve.
I have code design below:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebFormTest2.aspx.cs" Inherits="PerfexBankSystem.WebFormTest2" %>
That:
ajaxToolkit:TabContainer and ajaxToolkit:TabPanel that ajaxToolkit:TabPanel in ajaxToolkit:TabContainer. I use ajaxToolkit:TabContainer is dynamic that we get data from some table in database. Ex: if we have table 5, we will have
TabPanel 5. If we have table 6, we will have TabPanel 6. Tthat each table have dynamic control(TextBox, Dropdownlist, RadioButtonList)
and I can get data show on each TabPanel already. But it have problem when i add some button for make action, It have show error
below:
Line: 4723
Error: Sys.WebForms.PageRequestManagerServerErrorException: Specified argument was out of the range of valid values.
Parameter name: index
Please see code behide:
public void LoadTab()
{
SqlConnection Cnn = new clssDBConnection().dbConnection();
string str = " Select a.EDIID,a.FieldType,b.Value,b.Description,a.FieldName,a.FieldCaption,c.ObjectName, c.ObjectType, a.Available " +
" From Tbl_EmployeeDependencyInformation a, tbl_EmployeeDependencyObject b, tbl_customerFieldObject c " +
" Where a.EDOID=b.EDOID and a.ObjectHandler=c.ObjectID and Available=1";
cmd = new SqlCommand(str, Cnn);
cmd.ExecuteNonQuery();
SqlDataReader dr = cmd.ExecuteReader();
textbox = new TextBox();
String strTab = "";
AjaxControlToolkit.TabPanel tab = new AjaxControlToolkit.TabPanel();
TextBox tbx = new TextBox();
DropDownList drp = new DropDownList();
RadioButtonList rdo = new RadioButtonList();
Label lb = new Label();
Table tbl = new Table();
TableRow tRow = new TableRow();
TableCell tCell = new TableCell();
while (dr.Read())
{
tCell = new TableCell();
tRow = new TableRow();
tbl = new Table();
tbl.ID = dr["Value"].ToString();
tab.Controls.Add(tbl);
//tbl.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(3);
tCell.Controls.Add(new LiteralControl("
tRow.Cells.Add(tCell);
if (!strTab.Equals(dr["Value"].ToString()))
{
strTab = dr["Value"].ToString();
tab = new AjaxControlToolkit.TabPanel();
tab.ID = "tab" + dr["Value"].ToString();
tab.HeaderText = dr["Description"].ToString();
if (dr["ObjectType"].ToString().Equals("TextBox"))
{
lb = new Label();
lb.Text = dr["FieldCaption"].ToString();
tbx = new TextBox();
tbx.ID = "txt" + dr["FieldName"].ToString();
tCell.Controls.Add(tbx);
//tab.Controls.Add(lb);
// tab.Controls.Add(tbx);
}
if (dr["ObjectType"].ToString().Equals("DropdownList"))
{
lb = new Label();
lb.Text = dr["FieldCaption"].ToString();
drp = new DropDownList();
drp.ID = "drp" + dr["FieldName"].ToString();
string sql = " Select EDF.Value, EDF.EDIFieldValueID " +
" from tbl_EmployeeDependencyfieldvalue EDF, Tbl_EmployeeDependencyInformation EDI" +
" where EDF.EDIID = EDI.EDIID " +
" and EDF.EDIID ='" + dr["EDIID"].ToString() + "'";
DAdapter = new SqlDataAdapter(sql, Cnn1);
DataTable dtable = new DataTable();
DAdapter.Fill(dtable);
drp.DataTextField = "Value";
drp.DataValueField = "EDIFieldValueID";
drp.DataSource = dtable;
drp.DataBind();
drp.Width = System.Web.UI.WebControls.Unit.Pixel(285);
tCell.Controls.Add(drp);
//tab.Controls.Add(lb);
// tab.Controls.Add(drp);
}
if (dr["ObjectType"].ToString().Equals("RadioButtonList"))
{
lb = new Label();
lb.Text = dr["FieldCaption"].ToString();
rdo = new RadioButtonList();
rdo.ID = "rdo" + dr["FieldName"].ToString();
string sql = " Select EDF.Value, EDF.EDIFieldValueID " +
" from tbl_EmployeeDependencyfieldvalue EDF, Tbl_EmployeeDependencyInformation EDI" +
" where EDF.EDIID = EDI.EDIID " +
" and EDI.EDIID ='" + dr["EDIID"].ToString() + "'";
DAdapter = new SqlDataAdapter(sql, Cnn1);
DataTable dtable = new DataTable();
DAdapter.Fill(dtable);
rdo.DataTextField = "Value";
rdo.DataValueField = "EDIFieldValueID";
rdo.DataSource = dtable;
rdo.SelectedIndex = 0;
rdo.DataBind();
tCell.Controls.Add(rdo);
//tab.Controls.Add(lb);
//tab.Controls.Add(rdo);
}
tbl.Rows.Add(tRow);
TabContainer1.Tabs.Add(tab);
}
else
{
if (dr["ObjectType"].ToString().Equals("TextBox"))
{
lb = new Label();
lb.Text = dr["FieldCaption"].ToString();
tbx = new TextBox();
tbx.ID = "txt" + dr["FieldName"].ToString();
tCell.Controls.Add(tbx);
//tab.Controls.Add(lb);
// tab.Controls.Add(tbx);
}
if (dr["ObjectType"].ToString().Equals("DropdownList"))
{
lb = new Label();
lb.Text = dr["FieldCaption"].ToString();
drp = new DropDownList();
string sql = " Select EDF.Value, EDF.EDIFieldValueID " +
" from tbl_EmployeeDependencyfieldvalue EDF, Tbl_EmployeeDependencyInformation EDI" +
" where EDF.EDIID = EDI.EDIID " +
" and EDF.EDIID ='" + dr["EDIID"].ToString() + "'";
DAdapter = new SqlDataAdapter(sql, Cnn1);
DataTable dtable = new DataTable();
DAdapter.Fill(dtable);
drp.DataTextField = "Value";
drp.DataValueField = "EDIFieldValueID";
drp.DataSource = dtable;
drp.DataBind();
drp.ID = "drl" + dr["FieldName"].ToString();
drp.Width = System.Web.UI.WebControls.Unit.Pixel(285);
// tab.Controls.Add(lb);
//tab.Controls.Add(drp);
tCell.Controls.Add(drp);
}
if (dr["ObjectType"].ToString().Equals("RadioButtonList"))
{
lb = new Label();
lb.Text = dr["FieldCaption"].ToString();
rdo = new RadioButtonList();
rdo.ID = "rdo" + dr["FieldName"].ToString();
string sql = " Select EDF.Value, EDF.EDIFieldValueID " +
" from tbl_EmployeeDependencyfieldvalue EDF, Tbl_EmployeeDependencyInformation EDI" +
" where EDF.EDIID = EDI.EDIID " +
" and EDI.EDIID ='" + dr["EDIID"].ToString() + "'";
DAdapter = new SqlDataAdapter(sql, Cnn1);
DataTable dtable = new DataTable();
DAdapter.Fill(dtable);
rdo.DataTextField = "Value";
rdo.DataValueField = "EDIFieldValueID";
rdo.DataSource = dtable;
rdo.SelectedIndex = 0;
rdo.DataBind();
// tab.Controls.Add(lb);
// tab.Controls.Add(rdo);
tCell.Controls.Add(rdo);
}
}
tbl.Rows.Add(tRow);
}
dr.Close();
TabContainer1.Tabs.RemoveAt(0);
}
I think this error of couse this sub procedure. Becuse I close this sub procedure and click button, It not show error.
Whis you can help me.
Thank Advance
7 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsForums
Top experts
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit ChoudharyRank #145 · 15.8K reputationPosted Nov 25, 2009, 7:37 PM EST
I have write some code for you about having problem of how to identify which tab is selected?? or on which tab controls are to be added..
Please Dont forget to mark the answer :) it'll help me to get some points...
Download the project from here
Amit ChoudharyRank #145 · 15.8K reputationPosted Nov 23, 2009, 8:52 PM EST
your error is because of run time callback exception.... no need to worry about the ajax control they are fine in your code.....
mark the answer if it helps.. :)
Manath Pathana86 reputationPosted Nov 23, 2009, 10:56 PM EST
But you can correct it by give some code for me.
now it still error. I want some code from you.
Thank
Amit ChoudharyRank #145 · 15.8K reputationPosted Nov 25, 2009, 2:28 AM EST
Amit ChoudharyRank #145 · 15.8K reputationPosted Nov 25, 2009, 2:54 AM EST
Here is an example of ajaxTabControl....
but if you want me to write some code for your problem then send me your requirements....
Manath Pathana86 reputationPosted Nov 25, 2009, 5:40 PM EST
Firstly, all table name are stored in one table then I used data reader to read all the names of table and then load the number of header text depend on the amount of table names that we store in table.
Secondly, dynamic control loaded on the tab depend on it table name
Value field represent the name on tab and text and FieldName and ObjectName are the dynamic control that loaded on table in Value field.
When I Click Button Add how can I know that I am standing on that tab and Insert to correct table?
Please See some code that I write in design below:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebFormTest2.aspx.cs" Inherits="PerfexBankSystem.WebFormTest2" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Pagetitle>
head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblPerformerVisa" runat="server" Text="Label">asp:Label>
<asp:Label ID="Label1" runat="server" Text="Label">asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label">asp:Label>
<asp:Label ID="Label3" runat="server" Text="Label">asp:Label>
ContentTemplate>
asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Add" onclick="Button1_Click"/>
ContentTemplate>
asp:UpdatePanel>
form>
body>
html>
For Code Behide You can write about the process.
Lalit MRank #1,186 · 1.5K reputationPosted Nov 25, 2009, 6:42 PM EST
please visit this link for same thread may be help to you,
you will get more info from this link.