如何在aspx页面的for循环中获取字符串长度 [英] How to get string length in for loop of aspx page

查看:176
本文介绍了如何在aspx页面的for循环中获取字符串长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用for循环在aspx页面中使用的字符串长度。此字符串长度将从后面的代码计算数据库值计数,并且该值将被检索到aspx页面以获取for循环条件。如何实现这一点请任何人给我建议。但我得到的错误是:当前上下文中不存在计数这个名称。



我尝试了什么:



i required string length to use in aspx page using for loop. This string length will be calculate the database values count from code behind and that value will be retrieved to aspx page for for loop condition. how to achieve this please anybody give me suggestion. But i am getting error saying: The name 'count' does not exist in the current context.

What I have tried:

<asp:UpdatePanel ID="upQuestionsAndChoiceTabPanel" runat="server">
    <ContentTemplate>
        <cc1:TabContainer ID="OnlineTestTab" runat="server" AutoPostBack="true" ActiveTabIndex="1">
            <% for (int i = 0; i < count.Length; i++)
            { %>
                <cc1:TabPanel></cc1:TabPanel>
            <%} %>
        </cc1:TabContainer>
    </ContentTemplate>
</asp:UpdatePanel>



代码背后:

公共字符串数量;

此计数将在page_load事件中绑定数据库中的数据。那个计数长度我需要任何人请帮助我


In code behind:
public string count;
This count will bind data from database in page_load event. That count length i require anybody please help me

推荐答案

在字符串变量中读取该编辑器值然后你可以使用string.Length属性找到计数。



Read that editor value in a string variable and then you can find the count using string.Length property.

string test="Code Project";
int count=test.Length;


这篇关于如何在aspx页面的for循环中获取字符串长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆