使用Asp.net在C#中的下一个按钮 [英] Next button in C # using Asp.net

查看:53
本文介绍了使用Asp.net在C#中的下一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  protected   void  next1_Click(对象发​​件人,EventArgs e)
{
if (inc!= Maxrows)
{
inc ++;
Records();
Label2.Text = inc.ToString();
inc ++;
}
}





我希望使用上面的代码来输出下一条记录但是它只执行一次。我该怎么办呢?



添加了代码块,添加了ASP.NET标签[/ Edit]

解决方案

你应该使用while / do while循环来对它进行排序。你给出的代码总是将结果显示在同一个标​​签中。所以你需要改变它。为了检查条件你必须在其中使用任何循环的次数。


你好,



你检查了当你试图不止一次执行时,inc和Maxrows。你的'if'条件是否满足?


这是一个在循环中显示值的示例。



< pre lang =c#> int a = 5 ;
while (a < 10
{
ListBox1.Items.Add(Convert.ToString(a));
a ++;
}


protected void next1_Click(object sender, EventArgs e)
    {
        if (inc != Maxrows)
        {
            inc++;
            Records();
            Label2.Text = inc.ToString();
            inc++;
        }
    }



I wish to use the above code so as to output the next record but it it only executes once. How can I go about it?

[Edit]Code block added, ASP.NET tag added[/Edit]

解决方案

You should use a while/do while loop in order to sort this out.Also the code you have given is always displays the result in the same label.So you need to change that.In order to check the condition number of times you have to use any loop inside that.


Hi,

Did you check the values of the "inc" and "Maxrows" when you are trying to execute more than once. Is your ''if'' condition satisfied ?


This is a sample example for displaying values in loop..

int a = 5;
       while (a < 10)
       {
           ListBox1.Items.Add(Convert.ToString(a));
           a++;
       }


这篇关于使用Asp.net在C#中的下一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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