简体   繁体   English

(webform)如何从9个不同的文本框中获取值并回传值,然后升序

[英](webform) how can i get the value from 9 different textbox and post back the value follow by ascending

This is the code for webform(asp.net c#): 这是webform(asp.net c#)的代码:

 protected void Button2_Click(object sender, EventArgs e)
{
    int no1;
    int no2;
    int no3;
    int no4;
    int no5;
    int no6;
    int no7;
    int no8;
    int no9;

    no1 = int.Parse(txt1.Text);
    no2 = int.Parse(txt2.Text);
    no3 = int.Parse(txt3.Text);
    no4 = int.Parse(txt4.Text);
    no5 = int.Parse(txt5.Text);
    no6 = int.Parse(txt6.Text);
    no7 = int.Parse(txt7.Text);
    no8 = int.Parse(txt8.Text);
    no9 = int.Parse(txt9.Text);


    int[] a = new int[] {no1,no2,no3,no4,no5,no6,no7,no8,no9 };

    Array.Sort(a);

    foreach (var str in a)
    {
          MessageBox.Show(str.ToString()); //display in MessageBox, but i want to display back to 9 different textbox.
    }

I can display the result in MessageBox. 我可以在MessageBox中显示结果。 but I can't display the result back to 9 different textbox. 但我无法将结果显示回9个不同的文本框。 How can i find the solution? 我如何找到解决方案? Thank you This is the output http://i.gyazo.com/a91f7ffef1d6d1fa7815890464df3082.png 谢谢这是输出http://i.gyazo.com/a91f7ffef1d6d1fa7815890464df3082.png

txt1.Text = a[0];
txt2.Text = a[1];
txt3.Text = a[2];
txt4.Text = a[3];
txt5.Text = a[4];
txt6.Text = a[5];
txt7.Text = a[6];
txt8.Text = a[7];
txt9.Text = a[8];

This should do the job, if I understood you correctly. 如果我对您的理解正确,那么应该可以完成这项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM