错误因为String必须正好是一个字符长。 [英] error as String must be exactly one character long.
本文介绍了错误因为String必须正好是一个字符长。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友
以下是我为gridview进行rowupdating事件的代码。
comp.SECTIONID = Convert.ToInt32(sectiongrid.DataKeys [e.RowIndex] .Value.ToString());
comp.SECTIONNAME = Convert.ToChar(((TextBox)sectiongrid.Rows [e.RowIndex] .Cells [2] .Controls [0])。Text.ToString());
comp.CLASSNAME =< code>< / code>((TextBox)sectiongrid.Rows [e.RowIndex] .Cells [3] .Controls [0])。Text.ToString();
comp.MEDIUM =((TextBox)sectiongrid.Rows [e.RowIndex] .Cells [4] .Controls [0])。Text.ToString();
我在更新时将Sectionname从C设置为B但出现上述问题。
解决方案
试试这段代码。可能不是最好的解决方案。
comp.SECTIONNAME =((TextBox)sectiongrid.Rows [e.RowIndex] .Cells [ 2 ]。控制[ 0 ])。Text.ToString()[ 0 跨度>
Hi friends
The below is my code for rowupdating event for gridview.
comp.SECTIONID = Convert.ToInt32(sectiongrid.DataKeys[e.RowIndex].Value.ToString()); comp.SECTIONNAME =Convert.ToChar( ((TextBox)sectiongrid.Rows[e.RowIndex].Cells[2].Controls[0]).Text.ToString()); comp.CLASSNAME=<code></code>((TextBox)sectiongrid.Rows[e.RowIndex].Cells[3].Controls[0]).Text.ToString(); comp.MEDIUM = ((TextBox)sectiongrid.Rows[e.RowIndex].Cells[4].Controls[0]).Text.ToString();
I set the Sectionname from C to B in updating but the above problem is occur.
解决方案
Try this code. May not be the best solution.
comp.SECTIONNAME =((TextBox)sectiongrid.Rows[e.RowIndex].Cells[2].Controls[0]).Text.ToString()[0]
这篇关于错误因为String必须正好是一个字符长。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文