PDA

View Full Version : سوال: چرا وقتی یکی از فیلدهای جدول رو لیست باکس میذارم error میده؟



bamzi software
شنبه 19 بهمن 1387, 17:39 عصر
سلام

من در محیط "کد شارژ استودیو" یک grid and record builder تو صفحه گذاشتم..

در جدول رکورد ،"control type" مربوط به یکی از فیلد ها رو از نوع listbox گذاشتم که از یکی از جداول دیتابیس ،دیتا رو بخونه...

حالا مشکلم اینه که موقع load شدن صفحه وقتی جدول دیتا بیس پر باشه error میده:


Cannot find column 1.

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.IndexOutOfRangeException: Cannot find column 1.

Source Error:

Line 803: }
Line 804: for(int li=0;li<ListBoxSource.Count;li++){
Line 805: object val = ListBoxSource[li][1];
Line 806: string key = (new TextField("", ListBoxSource[li][0])).GetFormattedValue("");
Line 807: item.nameleegItems.Add(key,val);
Source File: c:\Inetpub\wwwroot\NewProject6\App_Code\admin_form e_mosabeghatDataProvider.cs Line: 805

Stack Trace:

[IndexOutOfRangeException: Cannot find column 1.]
System.Data.DataColumnCollection.get_Item(Int32 index) +80
System.Data.DataRow.get_Item(Int32 columnIndex) +13
NewProject6.admin_forme_mosabeghat.mosabeghat1Data Provider.FillItem(mosabeghat1Item item, Boolean& IsInsertMode) in c:\Inetpub\wwwroot\NewProject6\App_Code\admin_form e_mosabeghatDataProvider.cs:805
NewProject6.admin_forme_mosabeghat.admin_forme_mos abeghatPage.mosabeghat1Show() in c:\Inetpub\wwwroot\NewProject6\admin_forme_mosabeg hat.aspx.cs:225
NewProject6.admin_forme_mosabeghat.admin_forme_mos abeghatPage.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\NewProject6\admin_forme_mosabeg hat.aspx.cs:57
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

ولی اگه جدول دیتابیس خالی باشه صفحه load میشه.

ممنون میشم راهنماییم کنید.

bamzi software
یک شنبه 20 بهمن 1387, 21:48 عصر
حتی وقتی یک listbox تو صفحه خالی میذارم و دیتاشو تنظیم میکنم که از دیتابیس، یک ستون جدول رو بخونه بازم همین error رو میده!!!!

bamzi software
سه شنبه 29 بهمن 1387, 15:38 عصر
مشکلم حل شد:چشمک: