I seem to always have problems with this. I have a button outside of the View that calls a function that needs an OrderNumber
. I keep getting an error,
There should be a TemplateField as below:
Then you could access it this way:
string sOrderNumber = ((TextBox)Order_DetailsView.Rows[0].Cells[0].FindControl("txtOrderNo")).Text;
And for the BoundField
value you can do this way:
protected void Order_DetailsView_DataBound(object sender, EventArgs e)
{
string MyOrderNumber = Order_DetailsView.Rows[0].Cells[0].Text;
}