DataView does not exist error

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>
 
A

avnrao

your aspx doesnt know dv1 variable. try binding the value in your code
behind instead of putting the code in aspx file.

Av.
 
S

Steve Bishop

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top