DataView does not exist error

  • Thread starter Thread starter Steve Bishop
  • Start date Start date
S

Steve Bishop

I'm getting an error that my view does not exist. I get this error when
trying to bind to a text box on my form:
Help apprecaited. Thanks.

Compiler Error Message: CS0103: The name 'dv1' does not exist in the
class or namespace 'ASP.Relation_with_txtBoxes_aspx'
Source Error:
Line 87: <asp:TextBox id="TextBox3" runat="server" Text='<%#
dv1(0)("CustomerNumber") %>'></asp:TextBox>

//DataAdapter Setup
OdbcDataAdapter adapter = new OdbcDataAdapter(strSQL, myConn);

//DataSet, DataAdapter & Table
DataSet objDataSet = new DataSet();
adapter.Fill(objDataSet, "dtAR1");

//Set up a filter to use the text box value...
String Filter = "CustomerNumber = 'ABF'";

objDataSet.Tables[0].DefaultView.RowFilter = Filter;
objDataSet.Tables["dtAR1"].DefaultView.RowFilter = Filter;

//Create DataTable & DataView to feed single text box values on
form.....
DataTable dtAR1 = objDataSet.Tables["dtAR1"];
DataView dv1 = new DataView(dtAR1);

dgAR1.DataSource = objDataSet.Tables["dtAR1"];

Page.DataBind();

html....
<asp:TextBox id="TextBox3" runat="server" Text='<%#
dv1(0)("CustomerNumber") %>'></asp:TextBox>
 
your aspx doesnt know dv1 variable. try binding the value in your code
behind instead of putting the code in aspx file.

Av.
 
I think this is what you mean: Instead, I tried to put the code up in my
Page_Load and I get this now:

Compiler Error Message: CS0118: 'dv1' denotes a 'variable' where a
'method' was expected
Source Error:
Line 33: DataTable dtAR1 = objDataSet.Tables["dtAR1"];
Line 34: DataView dv1 = new DataView(dtAR1);
Line 35: TextBox3.Text = dv1(0)("CustomerNumber");

So all the code is on the Page_Load, but still getting errors. Help
appreciated.
 
Back
Top