TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Phani Kumar
NA
162
24.8k
while accessing values from dynamic controls getting error
Mar 5 2016 2:44 AM
Hi All,
I have created dynamic textboxes in a panel and trying to save them into database as a XML file, but I am receiving an error like
Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControl'
Here is my piece of code which I have written
StringBuilder _StrResult = new StringBuilder();
_StrResult.Append("<root>");
foreach (TextBox txt in pnlInterview.Controls)
{
foreach (Label lbl in pnlInterview.Controls)
{
Label lblLevel = (Label)pnlInterview.FindControl("lbl");
TextBox txtInterviewRound = (TextBox)pnlInterview.FindControl("txt");
_StrResult.Append("<InterviewLevel>");
_StrResult.Append("<level>" + lblLevel.Text.ToString() + "</level>");
_StrResult.Append("<RoundName>" + txtInterviewRound.Text.ToString() + "</RoundName>");
_StrResult.Append("</InterviewLevel>");
}
}
_StrResult.Append("</root>");
return _StrResult;
Unable to recognize where it went wrong
I am unable to access oftype(<Textbox>)
at starting foreach loop only I am receiving this error
any help is appreciated
Reply
Answers (
9
)
how to set page size half of A4 size on rdlc in c#
Write < and > in place of < and > in text file