---
title: "Get the value of a BoundField from a DetailsView"  
description: "Get the value of a BoundField from a DetailsView"  
author: "Royce Roy"  
published: 2014-12-03  
updated: 2014-12-04  
canonical: https://www.mindstick.com/forum/12737/get-the-value-of-a-boundfield-from-a-detailsview  
category: "asp.net"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Get the value of a BoundField from a DetailsView

I seem to always have problems with this. I have a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) outside of the View that calls a [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) that needs an OrderNumber. I keep [getting an error](https://answers.mindstick.com/qa/95244/why-do-you-keep-getting-an-error-message-ox800ccc0b),

ArgumentOutOfRangeException was unhandled by user code

in [debug mode](https://www.mindstick.com/interview/23356/how-can-you-test-bundling-in-debug-mode), or this one in the [browser](https://www.mindstick.com/blog/155254/which-is-the-best-internet-browser),

Specified argument was out of the [range](https://www.mindstick.com/articles/23243/complete-troubleshooting-tips-for-belkin-n300-range-extender-setup) of valid values.

## This is how I'm accessing it:

```
string sOrderNumber =(Order_DetailsView.Rows[0].Cells[0].Controls[0] as TextBox).Text;int orderNumber = Int32.Parse(sOrderNumber);
```

I've also tried (([TextBox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview))Order_DetailsView.Rows[0].Cells[0].Controls[0]).Text and every combination of [indexes](https://www.mindstick.com/articles/12525/indexes-in-sql-server) in Rows[i].Cells[i].Controls[i] that I could fathom.

## Here is the DetailsView:

```
<asp:DetailsView ID="Order_DetailsView"runat="server" AutoGenerateRows="False">    <Fields>        <asp:BoundField DataField="OrderNumber" HeaderText="Order #" />       
<asp:BoundField DataField="GST" HeaderText="GST" DataFormatString="{0:c}" />       
<asp:BoundField DataField="Total" HeaderText="Total" DataFormatString="{0:c}" />    </Fields></asp:DetailsView>
```

Am I just doing this all wrong? I've looked at every example out there I could find, and my code looks legit from what I can tell. I feel like there must be some [simple](https://yourviews.mindstick.com/story/1469/5-simple-ways-to-stay-fit-amp-healthy) thing I'm overlooking.

## Replies

### Reply by Anonymous User

```
There is no textbox in your details its a Cell. So u need to change your code.string sOrderNumber =Order_DetailsView.Rows[0].Cells[0].Text.ToString();int orderNumber = Int32.Parse(sOrderNumber);
```


---

Original Source: https://www.mindstick.com/forum/12737/get-the-value-of-a-boundfield-from-a-detailsview

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
