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