0
 protected void ImageButton16_Click(object sender, ImageClickEventArgs e)
    {
        if (Session["login"].ToString() == "true")
        {
            int i = 0;
            foreach (DataListItem Item in DataList1.Items)
            {
                Label id = (Label)DataList1.Controls[i].FindControl("ID");
                Label bidcount = (Label)DataList1.Controls[i].FindControl("Label7");
                string email = Session["username"].ToString();
                TextBox bid = (TextBox)DataList1.Controls[i].FindControl("TextBox1");
                if (bid.Text != "")
                {
                if (int.Parse(bid.Text) < int.Parse(bidcount.Text))
                {


                String script = "<SCRIPT LANGUAGE='JavaScript'> ";
                script += "AddConfirmbid()";
                script += "</SCRIPT>";
                Page.RegisterClientScriptBlock("ClientScript", script);
                }
                else
                {
                    String script = "<SCRIPT LANGUAGE='JavaScript'> ";
                    script += "invalidbid()";
                    script += "</SCRIPT>";
                    Page.RegisterClientScriptBlock("ClientScript", script);
                }
            }
            else
            {
                String script = "<SCRIPT LANGUAGE='JavaScript'> ";
                script += "enterbid()";
                script += "</SCRIPT>";
                Page.RegisterClientScriptBlock("ClientScript", script);
            }
            i++;
        }

    }
    else
    {
        String script = "<SCRIPT LANGUAGE='JavaScript'> ";
        script += "login()";
        script += "</SCRIPT>";
        Page.RegisterClientScriptBlock("ClientScript", script);
    }

}

4

1 回答 1

0

您的代码中的问题是您以错误的方式搜索文本框。我希望打击代码能帮助您获得文本框的正确值。

foreach (DataListItem item in DataList1.Items)
        {
            TextBox bid = (TextBox)item.FindControl("TextBox1");

            string text = bid .text;
            // Do whatever you need with that string value here
        }
于 2013-05-10T06:37:26.837 回答