I have a FormView (FormView1) that is populated when the user selects a value in a dropdown list (ddList1). This all works ok. I am trying to apply a background colour to a label in FormView1 when the Value = "Y". This works ok.
The problem I have is when the user selects a value in ddList1 that has no records in FormView1 then the page errors rather than just appearing with no data.
The problem I have is when the user selects a value in ddList1 that has no records in FormView1 then the page errors rather than just appearing with no data.
According to your description, I can't reproduce your question.
And since FormView is populated by the user select a value in a dropdownlist, then in what scene FormView will not record?
My suggestion is to set breakpoints and debug your code when formview has no records.
If you still can't solve the problem, please post your aspx and aspx.cs code.
Best regards,
Sam
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
48 Points
149 Posts
FormView Conditional Format Error
Oct 21, 2019 06:12 PM|Billson3000|LINK
Hello Experts,
I have a FormView (FormView1) that is populated when the user selects a value in a dropdown list (ddList1). This all works ok. I am trying to apply a background colour to a label in FormView1 when the Value = "Y". This works ok.
The problem I have is when the user selects a value in ddList1 that has no records in FormView1 then the page errors rather than just appearing with no data.
Here is my c#
I really appreciate any help someone could give me on this one!
Billson3000
All-Star
52813 Points
15768 Posts
Re: FormView Conditional Format Error
Oct 22, 2019 12:18 AM|oned_gk|LINK
Try check FormView1.PageCount > 0 before FindControls inside it
Suwandi - Non Graduate Programmer
Contributor
3370 Points
1409 Posts
Re: FormView Conditional Format Error
Oct 22, 2019 01:43 AM|samwu|LINK
Hi Billson3000,
According to your description, I can't reproduce your question.
And since FormView is populated by the user select a value in a dropdownlist, then in what scene FormView will not record?
My suggestion is to set breakpoints and debug your code when formview has no records.
If you still can't solve the problem, please post your aspx and aspx.cs code.
Best regards,
Sam
Member
48 Points
149 Posts
Re: FormView Conditional Format Error
Oct 22, 2019 05:12 AM|Billson3000|LINK
Here is my full cs corrected following advice from oned_gk. I am currently trying this on FormView Pre-render. This now works. Thanks very much oned.