الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

i can't solve the error in that code

مغلق
بدأه aroma في 28 يناير 2005 · 4 رد · 500 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Alsalam alikom,

this small code is a test

i tried to fil ddlist with data then when choosing a record another drop down list is to be filled with the correct data

اقتباس
this.sqlDataAdapter1.Fill(dspbinfo1);

  this.DropDownList1.DataBind();

  DataRelation dr;

      DataColumn parentcol;

      DataColumn childcol;

      parentcol =dspbinfo1.Tables["pub_info"].Columns["pub_id"];

      childcol =dspbinfo1.Tables["publishers"].Columns["pub_id"];

      dr=new DataRelation("pubinf",parentcol,childcol);

      dspbinfo1.Relations.Add(dr);

      DataView parentTableView =new DataView(dspbinfo1.Tables["pub_id"]);

      DataRowView currentrowview =parentTableView[DropDownList1.SelectedIndex];

      this.DropDownList2.DataSource=currentrowview.CreateChildView("pubinf");

      this.DropDownList2.DataBind();

and the error

اقتباس
Index 0 is not non-negative and below total rows count.

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: Index 0 is not non-negative and below total rows count.

Source Error:

Line 44:      dspbinfo1.Relations.Add(dr);

Line 45:      DataView parentTableView =new DataView(dspbinfo1.Tables["pub_id"]);

Line 46:      DataRowView currentrowview =parentTableView[DropDownList1.SelectedIndex];

Line 47:      this.DropDownList2.DataSource=currentrowview.CreateChildView("pubinf");

Line 48:      this.DropDownList2.DataBind();

i hope u can tell me how to solve the error line 46 is highlighted

#2

يا عم خليت دماغي تلف :wacko:

تقصد ايه ب

اقتباس
when choosing a record another drop down list is to be filled with the correct data

تم تعديل هذه المشاركة بواسطة mosad2 في 28 يناير 2005 في 18:41

#3

ye iam sorry i wrote it in a hurry

ok

what i needed to do is to have 2 drop down lists one of them i choose the index from it and the 2nd one is to list the data of that index like a publishers names or something

so i did a dataset to link the 2 tables

but i got that error on the run time

#4

first of all

U have to redefine ur solution!!

by other means try to benefit from the .NET controls and try a real world solution!

all u need here is a master details form

u bind a dataitem to ur dropdownlist

then after a user chooses an item from the drop down list u then display the details

or whatever u want in a datagrid or whatever u want

read this it will give u an example of all u want

TimeSheet Application HowTo

#5

Gazakom Allah khairan

i will try and tell you the result

Gazakom Allah Khaira again

هذا الموضوع مغلق.

مواضيع مشابهة