Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 21, 2012 09:54 AM by Frank Jiang - MSFT
Member
81 Points
196 Posts
Nov 16, 2012 05:20 PM|LINK
in the detail view , i have the user control and i like fill the propeties of that with
foreach (var file in fileList.Efiles)
but i have the error "object reference not to set an instance of an object" for (fileList.Efiles)
please help what is the problemthe complete code is like below:
public partial class DocResult : System.Web.UI.Page { private EDMSDataContext _DataContext; private int _TransmittalId; private int _DocId; protected void Page_Load(object sender, EventArgs e) { String tmpString1; String tmpString2; tmpString1 = Request.QueryString["DocId"]; if (String.IsNullOrEmpty(tmpString1)) throw new ArgumentNullException("DocId"); _DocId = Convert.ToInt32(tmpString1); tmpString2 = Request.QueryString["TransID"]; if (String.IsNullOrEmpty(tmpString2)) throw new ArgumentNullException("TransID"); _TransmittalId = Convert.ToInt32(tmpString2); _DataContext = new EDMSDataContext(); var query = _DataContext.spDocResult(_DocId, _TransmittalId); DetailsView1.DataSource = query.ToList(); DetailsView1.DataBind(); spDocResultResult docresult = (spDocResultResult)DetailsView1.DataItem; FileTemp fileList = (FileTemp)DetailsView1.FindControl("FileTemp1"); foreach (var file in fileList.Efiles) { file.FileName = docresult.Filename; } //fileList.Efiles = docresult.Filename; fileList.DataBind(); } }
Nov 16, 2012 05:29 PM|LINK
please help in this case
Star
13599 Points
2691 Posts
Nov 17, 2012 07:51 AM|LINK
Hi,
what is the FileTemp,
If you are looping by the time there is no file then it will give error...
All-Star
16006 Points
1728 Posts
Microsoft
Nov 21, 2012 09:54 AM|LINK
Judging from your code snippets, not sure this issue. Can you share your user control?thanks.
masoud-s
Member
81 Points
196 Posts
object reference not to set an instance of an object
Nov 16, 2012 05:20 PM|LINK
in the detail view , i have the user control and i like fill the propeties of that with
but i have the error "object reference not to set an instance of an object" for (fileList.Efiles)
public partial class DocResult : System.Web.UI.Page { private EDMSDataContext _DataContext; private int _TransmittalId; private int _DocId; protected void Page_Load(object sender, EventArgs e) { String tmpString1; String tmpString2; tmpString1 = Request.QueryString["DocId"]; if (String.IsNullOrEmpty(tmpString1)) throw new ArgumentNullException("DocId"); _DocId = Convert.ToInt32(tmpString1); tmpString2 = Request.QueryString["TransID"]; if (String.IsNullOrEmpty(tmpString2)) throw new ArgumentNullException("TransID"); _TransmittalId = Convert.ToInt32(tmpString2); _DataContext = new EDMSDataContext(); var query = _DataContext.spDocResult(_DocId, _TransmittalId); DetailsView1.DataSource = query.ToList(); DetailsView1.DataBind(); spDocResultResult docresult = (spDocResultResult)DetailsView1.DataItem; FileTemp fileList = (FileTemp)DetailsView1.FindControl("FileTemp1"); foreach (var file in fileList.Efiles) { file.FileName = docresult.Filename; } //fileList.Efiles = docresult.Filename; fileList.DataBind(); } }masoud-s
Member
81 Points
196 Posts
Re: object reference not to set an instance of an object
Nov 16, 2012 05:29 PM|LINK
please help in this case
sarathi125
Star
13599 Points
2691 Posts
Re: object reference not to set an instance of an object
Nov 17, 2012 07:51 AM|LINK
Hi,
what is the FileTemp,
If you are looping by the time there is no file then it will give error...
Remember to click Mark as Answer on the post that helps to others.
My Blog :MyAspSnippets
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: object reference not to set an instance of an object
Nov 21, 2012 09:54 AM|LINK
Judging from your code snippets, not sure this issue. Can you share your user control?thanks.
Feedback to us
Develop and promote your apps in Windows Store