'System.Web.UI.Control' does not contain a definition for 'DataItem'

Hi, 

I am recieving this error: 'System.Web.UI.Control' does not contain a definition for 'DataItem'
What iam trying to do is when a user clicks the hyperlink column in the datagrid then the ID of that user is send to another page and I need to run the Query or something and bind the Label on the page 2 with the name of the Person. So I am using the HTML view and writing something like this :
'<%# DataBinder.Eval(Container.DataItem,"Name") %> '
here is my code behind file so how can i bind the Name of the person with the label:
 

private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
// Checks to see if the Request Query String was not null
if(Request.QueryString["CustomerID"] != null)
{
int CustomerID = Convert.ToInt32(Request.QueryString["CustomerID"]);
//Label1.Text = CustomerID;


OleDbDataAdapter ad1 = new OleDbDataAdapter("SELECT * FROM Customers WHERE CustomerID="+CustomerID,myConnection);
OleDbDataAdapter ad2 = new OleDbDataAdapter("SELECT * FROM Purchases WHERE CustomerID="+CustomerID,myConnection);

DataSet ds1 = new DataSet();
ad1.Fill(ds1);
DataSet ds2 = new DataSet();
ad2.Fill(ds2);
myConnection.Open();
CustomerGrid.DataSource = ds1;
CustomerGrid.DataBind();
BooksGrid.DataSource = ds2;
BooksGrid.DataBind();
myConnection.Close();
}



}

HighOnCoding
Wanna get high!
-1
azamsharp
3/3/2004 4:56:17 AM
asp.net.presentation-controls 72751 articles. 2 followers. Follow

3 Replies
3108 Views

Similar Articles

[PageSpeed] 51

Remove the data binding bit from the label. In your code behind, just before binding the grid, let the Text property of the label. (I assume your label is defined outside of the grid)

label1.Text = ds1.Tables(0).Rows(0).Item("Surname")
Bug [MCSD]
1
Bug_Bugger
3/3/2004 10:26:41 AM
Hi,

There is no Method of Rows which is Item. ??
HighOnCoding
Wanna get high!
1
azamsharp
3/4/2004 5:03:21 AM
Yeah, that is an indexer in c#. It should be:


label1.Text = ds1.Tables(0).Rows(0)["Surname"].ToString();

Bug [MCSD]
1
Bug_Bugger
3/4/2004 9:07:54 AM
Reply: