Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
Session["Answered"] = dt;
	View v = this.View1;
 
	Label l = default(Label);
        l = (Label)v.FindControl("Label1");
        l.Text = dt.Rows[ctr].Item["Serial"] + ".";
        l = (Label)v.FindControl("Label2");
        l.Text = dt.Rows[ctr].Item["question"];

Error	4	'System.Data.DataRow' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Data.DataRow' could be found (are you missing a using directive or an assembly reference?)	E:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\WebSites\sravan\WebSite6\Default2.aspx.cs	38	31	E:\...\WebSite6\
Posted
Updated 19-Nov-11 23:08pm
v4

1 solution

DataRow does not have an Item property - try referencing the column instead...
C#
l.Text = dt.Rows[ctr]["Serial"] + ".";
 
Share this answer
 
Comments
2011999 20-Nov-11 5:14am    
l.Text = dt.Rows[ctr].Item["question"];

indexoutofrangeException unhandle by user code plz correct the above code
OriginalGriff 20-Nov-11 5:24am    
See my answer to your other question on this subject. If you don't put any rows in your DataTable, then you are going to get out-of-range exceptions when you try to access the rows it hasn't got!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900