CreateDynamicWizardSteps

CreateDynamicWizardSteps

本文介绍了输入字符串的格式不正确。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 此代码在加载页面时正常工作。当我清除所有控件并再次添加时,我收到此错误。请告诉我哪里做错了。 我尝试过: case StepTransition: if (UIControlsWizard.WizardSteps.Count == 0 ) { rbtnAddWizard.Attributes.Add( WizardCommand, CreateWizard& + commandData [ 2 ] + & + commandData [ 1 ]); RadScriptManager.RegisterClientScriptBlock( this , this .GetType(), btnClick _, document.getElementById(' + rbtnAddWizard.ClientID + ')。click();, true ); } break ; 受保护 void rbtnAddWizard_Click( object sender, EventArgs e) { string wizardCommand = rbtnAddWizard.Attributes [ WizardCommand]; if (!string.IsNullOrEmpty(wizardCommand)) { if (wizardCommand.Contains( CreateWizard)) CreateDynamicWizardSteps(Convert.ToInt32( wizardCommand.Split(' &')[ 2 ]),Convert.ToInt32(wizardCommand.Split(' &')[ 1 ])); // 这里我收到错误 else if (wizardCommand.Contains( RemoveWizardAndAdd)) { i f (UIControlsWizard.WizardSteps.Count!= 0 ) RemoveDynamicWizardSteps(); CreateDynamicWizardSteps(Convert.ToInt32(wizardCommand.Split(' &')[ 2 ]),Convert.ToInt32(wizardCommand.Split(' & ;')[ 1 ])); } else if (wizardCommand.Contains( RemoveWizard)) { RemoveDynamicWizardSteps(); // RadScriptManager.RegisterClientScriptBlock(this,this.GetType(),Script,stepChange() ,true); } } } 解决方案 拆分中的一个项目不是整数。 而不是使用 Convert.ToInt32 尝试使用 Int32.TryParse [ ^ ] - 至少你可以找到有问题的字符串 编辑:示例(未经测试) if(wizardCommand .Contains(CreateWizard)) { int chk1; int chk2; if(int32.TryParse(wizardCommand.Split('&')[2],out chk1)&& int32.TryParse(wizardCommand.Split('&')[1] ,out chk2)) { CreateDynamicWizardSteps(chk1,chk2); } 。 。 。我个人会做一次拆分并存储结果,然后在后续代码中使用结果,而不是每次我想引用其中一个元素时进行拆分 This code works fine when the page is loading. when i am clearing all the controls and adding once again i am getting this error. Please give an idea where i had done wrong.What I have tried:case "StepTransition": if (UIControlsWizard.WizardSteps.Count == 0) { rbtnAddWizard.Attributes.Add("WizardCommand", "CreateWizard&" + commandData[2] + "&" + commandData[1]); RadScriptManager.RegisterClientScriptBlock(this, this.GetType(), "btnClick_", "document.getElementById('" + rbtnAddWizard.ClientID + "').click();", true); } break;protected void rbtnAddWizard_Click(object sender, EventArgs e) { string wizardCommand = rbtnAddWizard.Attributes["WizardCommand"]; if (!string.IsNullOrEmpty(wizardCommand)) { if (wizardCommand.Contains("CreateWizard")) CreateDynamicWizardSteps(Convert.ToInt32(wizardCommand.Split('&')[2]), Convert.ToInt32(wizardCommand.Split('&')[1]));//Here i am getting the error else if (wizardCommand.Contains("RemoveWizardAndAdd")) { if(UIControlsWizard.WizardSteps.Count!=0) RemoveDynamicWizardSteps(); CreateDynamicWizardSteps(Convert.ToInt32(wizardCommand.Split('&')[2]), Convert.ToInt32(wizardCommand.Split('&')[1])); } else if (wizardCommand.Contains("RemoveWizard")) { RemoveDynamicWizardSteps(); //RadScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Script", "stepChange()", true); } } } 解决方案 One of the items from your split is not an integer.Instead of using Convert.ToInt32 try using Int32.TryParse[^] - at the very least you will be able to find the offending stringEdit: Example (untested)if (wizardCommand.Contains("CreateWizard")){ int chk1; int chk2; if(int32.TryParse(wizardCommand.Split('&')[2], out chk1) && int32.TryParse(wizardCommand.Split('&')[1], out chk2)) { CreateDynamicWizardSteps(chk1, chk2); }. . .I would personally do the split once and store the results, then use the results in the subsequent code, rather than doing the split each time I want to reference one of the elements 这篇关于输入字符串的格式不正确。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-06 20:38