c# - Index outside of bounds of the array when using DataGrid View? -


I am trying to tie the array directly into grid view control, where I try to display details on grid view control I am doing

I have tried the code below, but it is throwing some errors. Please help me to find the right solution Thank you.

Code:

  Secure void ddlCircle_SelectedIndexChanged (Object Sender, EventArgs E) {ShadingAnalysisDataSetTableAdapters.tbl_CadEngineersTeamTableAdapter CD; CD = New Shading AnalysisDataTabAptaptors.blogEditorTemplateAdapter (); Datatable dt = new datatable (); Dt = cd.GetAvailableData (ddlCircle.SelectedValue); Int x, y; Datatelle dt3 = new datatile (); Dt3 = CD. Gettam (); Y = DT3 Ro.kount; X = dt.rows.Count; Datatelle dt2 = new datatile (); Dt2 = cd.GetAssignTeam (x); String [] strArr = new string [dt.Rows.Count]; Int i = 0; Testc: foreach (DataRow r in dt2.Rows) {strarr [i] = r ["Team"]. ToString (); I ++; If (i> = x - 1) {break; } If (i> = y) {Goto testc; }} GridView2.DataSource = strarr [i]; GridView2.DataBind (); }  

GridView2.DataSource = strarr [i]; This line probably will cause errors, is not it? This is because you type i in in your final iteration in dt2.Rows.Count + 1

  If (i> gt) GridView2.DataSource = strarr [i - 1];  

As the last line.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -