我寫過這段代碼將每個文本框的值綁定到標籤上,這對每個單獨的值都有效,但現在我希望標籤綁定每個數值次數意味着使用for循環爲此,我可以綁定不同的值併爲迭代次數動態顯示它,所以它怎麼可能。如何綁定不同數量的值的標籤
protected void Button1_Click(object sender, EventArgs e)
{
string name = TextBox1.Text;
string order = TextBox2.Text;
int qty = Convert.ToInt32(TextBox3.Text);
int rate = Convert.ToInt32(TextBox4.Text);
int discount = Convert.ToInt32(TextBox5.Text);
int c = (Convert.ToInt32(TextBox3.Text) * Convert.ToInt32(TextBox4.Text) - Convert.ToInt32(TextBox5.Text));
TextBox6.Text = c.ToString();
int total = Convert.ToInt32(TextBox6.Text);
string j="";
for (int i = 1; i < 5; i++)
{
j += i + "";
Label1.Text = j + "customer name is:-" + name;
Label2.Text = j + "order item is:-" + order;
Label3.Text = j + "quantity is:-" + qty;
Label4.Text = j + "rate of the item is:-" + rate;
Label5.Text = j + "discount given to the item is:-" + discount;
Label6.Text = j + "Total of the item is:-" + total;
}
TextBox1.Text = string.Empty;
TextBox2.Text = string.Empty;
TextBox3.Text = string.Empty;
TextBox4.Text = string.Empty;
TextBox5.Text = string.Empty;
TextBox6.Text = string.Empty;
}
您可以回來編輯您的問題 - 將其分解爲連貫的句子,並使用正常的句子框,創建適當的標題等。這會讓你更容易理解你的問題。 – slugster