Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6031941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:15:35+00:00 2026-05-23T05:15:35+00:00

public partial class login_activity_survey : PageHelperBase { protected System.Web.UI.WebControls.Label LblAnketSoru; protected System.Web.UI.WebControls.TextBox TxtFreeText; protected

  • 0
    public partial class login_activity_survey : PageHelperBase
{
    protected System.Web.UI.WebControls.Label LblAnketSoru;
    protected System.Web.UI.WebControls.TextBox TxtFreeText;
    protected System.Web.UI.WebControls.CheckBoxList ChkSecimler;
    protected System.Web.UI.WebControls.ListItem LiSecim;
    protected System.Web.UI.WebControls.RadioButtonList RdSecimler;
    protected System.Web.UI.WebControls.Literal Literalim;

    protected void Page_Load(object sender, EventArgs e)
    {
        string AnketId = ConfigurationManager.AppSettings["AnketId"].ToString();
        GenerateSurvey(AnketId, plc);
    }

    void GenerateSurvey(string AnketId, System.Web.UI.WebControls.PlaceHolder plch)
    {
        var db = new Xrm.XrmDataContext(Microsoft.Xrm.Client.CrmConnection.Parse(Utils.getXrmConnectionString(_PortalBrandHelper.BrandProxy.BrandDedicatedCrmOrgName)));

        var AnketSoru = from p in db.new_survey_questions
                        orderby p.new_rank
                        select new { p.new_survey_questionid, p.new_question_text, p.new_question_type, p.new_rank, p.new_min_enumerator, p.new_max_enumerator };


        HtmlTable tbl = new HtmlTable();
        tbl.CellPadding = 2;
        tbl.CellSpacing = 3;


        HtmlTableRow r = new HtmlTableRow();
        HtmlTableCell c = new HtmlTableCell();
        c.InnerHtml = "<h3>İMMİB</h3>";
        c.ColSpan = 2;
        c.Align = "center";
        r.Cells.Add(c);
        tbl.Border = 1;

        tbl.ID = "Survey_Inner";
        tbl.Rows.Add(r);
        c = new HtmlTableCell();
        r = new HtmlTableRow();
        c.ColSpan = 2;
        c.InnerHtml = "<h4>EĞİTİM DEĞERLENDİRME FORMU</h4>";
        c.Align = "center";
        r.Cells.Add(c);
        tbl.Rows.Add(r);
        foreach (var item in AnketSoru)
        {
            r = new HtmlTableRow();
            c = new HtmlTableCell();
            c.InnerHtml = item.new_question_text.ToString();
            r.Cells.Add(c);

            switch (item.new_question_type.ToString())
            {
                case "2": //FreeText
                    c = new HtmlTableCell();
                    TxtFreeText = new TextBox();
                    TxtFreeText.ID = "Txt_" + item.new_survey_questionid.ToString();
                    TxtFreeText.TextMode = TextBoxMode.MultiLine;
                    TxtFreeText.Width = 300;
                    TxtFreeText.Height = 50;
                    TxtFreeText.EnableViewState = true;
                    c.Controls.Add(TxtFreeText);
                    break;

                case "3": //CheckBox
                    c.ColSpan = 2;

                    var choises = from c1 in db.new_survey_question_choices
                                  where c1.new_survey_questionid == item.new_survey_questionid
                                  select c1;

                    ChkSecimler = new CheckBoxList();
                    ChkSecimler.ID = "Chkl_" + item.new_survey_questionid.ToString();
                    ChkSecimler.RepeatDirection = RepeatDirection.Horizontal;
                    ChkSecimler.RepeatColumns = 2;
                    ChkSecimler.Attributes.Add("class", "ChkCss");
                    foreach (var ck in choises)
                    {
                        LiSecim = new ListItem();
                        LiSecim.Text = ck.new_name;
                        ChkSecimler.Items.Add(LiSecim);
                    }

                    c.Controls.Add(ChkSecimler);
                    break;

                case "4": //Enumeration RadioButton
                    c = new HtmlTableCell();
                    RdSecimler = new RadioButtonList();
                    RdSecimler.ID = "Rdl_" + item.new_survey_questionid.ToString();
                    RdSecimler.RepeatDirection = RepeatDirection.Horizontal;
                    RdSecimler.CellPadding = 2;
                    c.Align = "center";
                    RdSecimler.Attributes.Add("class", "TblCss");



                    for (int i = Convert.ToInt32(item.new_min_enumerator); i <= Convert.ToInt32(item.new_max_enumerator); i++)
                    {
                        LiSecim = new ListItem();
                        LiSecim.Text = i.ToString();
                        RdSecimler.Items.Add(LiSecim);

                    }
                    c.Controls.Add(RdSecimler);
                    break;

                default:
                    break;

            }

            r.Cells.Add(c);

            tbl.Rows.Add(r);

        }

        plch.Controls.Add(tbl);

    }

and

void SaveAnswers(Guid ContactId, Guid ActivityAttendee, Guid QuestionId, string FreeTextCevap)
    {
        var db = new Xrm.XrmDataContext(Microsoft.Xrm.Client.CrmConnection.Parse(Utils.getXrmConnectionString(_PortalBrandHelper.BrandProxy.BrandDedicatedCrmOrgName)));

        Xrm.new_survey_answer answer = new Xrm.new_survey_answer();

        answer.new_participantid = ContactId;
        answer.new_activity_attendeeid = ActivityAttendee;
        answer.new_survey_questionid = QuestionId;
        answer.new_answer_text = FreeTextCevap;

        try
        {
            db.AddTonew_survey_answers(answer);
            db.SaveChanges();

        }
        catch (Exception)
        {
            throw;
        }


    }
    void SaveAnswers(Guid ContactId, Guid ActivityAttendee, Guid QuestionId, int EnumarationCevap)
    {
        var db = new Xrm.XrmDataContext(Microsoft.Xrm.Client.CrmConnection.Parse(Utils.getXrmConnectionString(_PortalBrandHelper.BrandProxy.BrandDedicatedCrmOrgName)));

        Xrm.new_survey_answer answer = new Xrm.new_survey_answer();

        answer.new_participantid = ContactId;
        answer.new_activity_attendeeid = ActivityAttendee;
        answer.new_survey_questionid = QuestionId;
        answer.new_answer_numeric_value = EnumarationCevap;

        try
        {
            db.AddTonew_survey_answers(answer);
            db.SaveChanges();
        }
        catch (Exception)
        {
            throw;
        }


    }
    void SaveAnswers(Guid ContactId, Guid ActivityAttendee, Guid QuestionId, Guid CheckboxCevap)
    {
        var db = new Xrm.XrmDataContext(Microsoft.Xrm.Client.CrmConnection.Parse(Utils.getXrmConnectionString(_PortalBrandHelper.BrandProxy.BrandDedicatedCrmOrgName)));

        Xrm.new_survey_answer answer = new Xrm.new_survey_answer();

        answer.new_participantid = ContactId;
        answer.new_activity_attendeeid = ActivityAttendee;
        answer.new_survey_questionid = QuestionId;
        answer.new_survey_question_choiceid = CheckboxCevap;

        try
        {
            db.AddTonew_survey_answers(answer);
            db.SaveChanges()
        }
        catch (Exception)
        {
            throw;
        }
    }

and

protected void SurveySubmit_Click(object sender, EventArgs e)
    {
        string AttendeeId = Request.QueryString.Get("atId") != null ? Request.QueryString.Get("atId").ToString() : string.Empty;

        Guid EgitimKatilimcisi = new Guid("9163DA6E-3E97-E011-8A8F-001517557A34");

        foreach (Control c in plc.Controls)
        {
            System.Web.UI.HtmlControls.HtmlTable Survey_Inner = (System.Web.UI.HtmlControls.HtmlTable)c.FindControl("Survey_Inner");
            foreach (System.Web.UI.HtmlControls.HtmlTableRow r in Survey_Inner.Rows)
            {
                foreach (Control ctr in r.Cells)
                {
                    foreach (Control ct in ctr.Controls)
                    {
                        if (ct.GetType().ToString() == "System.Web.UI.WebControls.TextBox")
                        {
                            string TextCevap = ((System.Web.UI.WebControls.TextBox)ct).Text;

                            string deger = ct.ID.ToString();

                            Guid QuestionId = new Guid(deger.Substring(4));

                            SaveAnswers(this._PortalUserHelper.UserProxy.ContactId, EgitimKatilimcisi, QuestionId, TextCevap);

                        }
                        else if (ct.GetType().ToString() == "System.Web.UI.WebControls.RadioButtonList")
                        {
                            int Enumaration = Convert.ToInt32(((System.Web.UI.WebControls.RadioButtonList)ct).SelectedValue);
                            string deger = ct.ID.ToString();

                            Guid QuestionId = new Guid(deger.Substring(4));

                            SaveAnswers(this._PortalUserHelper.UserProxy.ContactId, EgitimKatilimcisi, QuestionId, Enumaration);
                        }
                        else if (ct.GetType().ToString() == "System.Web.UI.WebControls.CheckBoxList")
                        {
                            int Cevap = Convert.ToInt32(((System.Web.UI.WebControls.CheckBoxList)ct).SelectedItem);

                            string deger = ct.ID.ToString();

                            Guid QuestionId = new Guid(deger.Substring(4));

                            SaveAnswers(this._PortalUserHelper.UserProxy.ContactId, EgitimKatilimcisi, QuestionId, Cevap);


                        }

I’ve problem with this second else if for checkboxlist the others (radiobutton and freetxt) are ok.

Line 250: else if (ct.GetType().ToString() == “System.Web.UI.WebControls.CheckBoxList”)
Line 251: {
Line 252: int Cevap = Convert.ToInt32(((System.Web.UI.WebControls.CheckBoxList)ct).SelectedItem);
Line 253:
Line 254: string deger = ct.ID.ToString();

Problem is on line 252

Server Error in ‘/’ Application.

‘System.Web.UI.WebControls.ListItem’ türündeki nesne ‘System.IConvertible’ türüne atılamadı.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: ‘System.Web.UI.WebControls.ListItem’ türündeki nesne ‘System.IConvertible’ türüne atılamadı.


I have a checkboxlist i want to take all the selected items and write into the crm. any help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:15:36+00:00Added an answer on May 23, 2026 at 5:15 am

    The problem in line 252 is because you’re passing a ListItem to the Convert.ToInt32() method, which doesn’t accept that type.

    Try changing it to:

    int Cevap = Convert.ToInt32(((System.Web.UI.WebControls.CheckBoxList)ct).SelectedValue);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the following master.cs code: public partial class Default : System.Web.UI.MasterPage { protected void
My master page: public partial class MasterPages_Main : System.Web.UI.MasterPage { public bool IsLoggedIn; protected
I have the following code: public partial class queryTerm : System.Web.UI.UserControl { private static
Why DisplayUsers(); doesn't work? My base page is: public class adminPage : System.Web.UI.Page {
using System; using System.Windows.Forms; using agsXMPP; using System.Text; namespace iTalk2 { public partial class
Given this class public partial class Default : Page { private IRepository repo; ...
Consider this source: public partial class FormTest : Form { private Test test {
say I have this control: public partial class bloc999 : UserControl { bloc999Data mainBlock
You should be able to create a generic form: public partial class MyGenericForm<T> :
I have a control that is created like so: public partial class MYControl :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.