Unable to get values of unbound fields in gridview asp.net c# -


i trying values gridview.

i use stored procedure set datasource it, let's gridview uses dynamic pivot colums can't create bound field them.

here code trying textbox value , header value

protected void dgvtask_selectedindexchanged(object sender, eventargs e) {     var grid = (gridview)sender;     gridviewrow selectedrow = grid.selectedrow;      int rowindex = grid.selectedindex;     int selectedcellindex = int.parse(this.selectedgridcellindex.value);      textbox txtlogs = (textbox)selectedrow.cells[selectedcellindex].findcontrol("txtdata");     string cellvalue = txtlogs.text;     string headervalue = grid.headerrow.cells[selectedcellindex].text;      scriptmanager.registerclientscriptblock(this, this.gettype(), "alertmessage", "alert('" + selectedcellindex + "')", true);     binddgvtask(); } 

i tried use

string cellvalue = grid.selectedrow.cells[selectedcellindex].text; 

to cell value both of these returns these error

specified argument out of range of valid values

selectedrow cannot wrong because returns value of row selected. check selectedcellindex return correct value base on clicked.

but when tried use row[0].cells[0] boundfield set

<columns>     <asp:boundfield datafield="task" headertext="task">         <controlstyle backcolor="white" bordercolor="black" />         <itemstyle backcolor="white" bordercolor="black" borderstyle="solid" forecolor="black" />     </asp:boundfield> </columns> 

it returns correct values.

so puzzled whether i'm doing retrieving of values wrong way or there different approach on getting values unbound field.

thanks in advance


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -