c# - Error Specified argument was out of the range of valid values. Parameter name: index in DataGridview Row Data Bound -


I got an error

Description: An uncontrolled exception occurred during the execution of the current For more information about the web request error, review the stack trace and where it started in the code.

Exception Description: System.ArgumentOutOfRangeException: The specified argument was outside the range of valid values ​​parameter name: index

source error:

 < Code> if (e.Row.RowType == DataControlRowType.DataRow) {LinkButton _singleClickButton = (LinkButton) e. Row.Cells [0] .Controls [2]; String _jsSingle = ClientScript.GetPostBackClientHyperLink (_singleClickButton, "$ Select + e.Row.RowIndex); E. Row Style [" Cursor "] =" Hands ";  

My code < / P>

  Protected Zero Page_load (object sender, event case e) {if (! This.IsPostBack) {DataTable dt = New DataTable (); New DataColumn (New Data Columns [3] (New "" Dataculation Dt.Rows.Add ("", "Data Id", "Data Type", Typef (String)), New Datacolm ("ITADCIC", TIFF (String)), New Data Column FG001 "," Red Velvet Cake (8 '' Round) "," Dry Value "); Dt.Rows.Add (" FG002 "," toilet velvet cake (8 '' round) "," dry baggage "); GridView1.DataSource = dt; GridView1.DataBind ();}} Safe audacity sender, Iventargs e) {Gridwuvr row = new Gridwuvo (0, 0, data Kantrolrv typed. headers, Datakantrolrvstet. General); for (Int i = 0; i & Lt; GridViewlkColumnkCount; I ++) { TableHeader Cell Cell = New TableHeaderCell (); Text Box txtSearch = New Text Box (); TxtSearch.Attributes ["Placeholder"] = GridView1.Columns [i] .HeaderText; TxtSearch.CssClass = "search_textbox"; Cell.Controls.Add (txtSearch); Row.Controls.Add (cell); } GridView1.HeaderRow.Parent.Controls.AddAt (1, line); } Protected void GridViewl_RowDataBound (object sender, GridViewRowEventArgs e) {if (! IsPostBack) {if (e. Rau. Rao type == DataControlRowTypekDataRow) {if (e. RO. Rao type == data Kantrolrv Taipkdetav) { LinkButton _singleClickButton = (LinkButton) e.Row.Cells [0] .Controls [0]; String _jsSingle = ClientScript.GetPostBackClientHyperlink (_singleClickButton, select "$ + + e.Row.RowIndex); e. Raw. Style [" cursor "] =" hand "; e. RO. Characteristic [" onclick "] = _jsSingle;} }}} protected void GridView1 Selektedindaksainjad (object sender, Iventaarjis e) {Gridwuruv Cynitro = GridView1. Select Garo; Hiddenitemid.Value = selectedRow.Cells [0]. text;}  

error indicates To do

  linkbutton _singleClickButton = (LinkButton E.RO.KEL [0]. [0];  

Either you have any cellular There are rows without, or you have cells with less than three control.

To prevent the code from crashing, just check that you have enough items:

  if (e.O.Cell.Count> gt; 0) {Table cell cell = E.RO.kel [0]; if (cell control calculation & gt; 2) {linkbutton_singleClickButton = (linkbutton) Cell Control [2]; String _jsSingle = ClientScript.GetPostBackClientHyperLink (_singleClickButton, "$ Select + e.Row.RowIndex); E. Rau Style ["cursor"] = "hand"; }}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -