Textbox ID of Items not working properly

161 views Asked by At

In my aspx, I have few textboxes. Some are straightforward textboxes and others are rendered output textboxes. The textboxes are mapped to received uploaded XML data to the site/database and it is also supposed to allow user to modify the data in textboxes.

<td>
  <asp:TextBox ID="TextBox1" runat="server" Text=""></asp:TextBox>
</td>
<td>
  <asp:TextBox ID="TextBox2" runat="server" Text=""></asp:TextBox>
</td>
<td>
  <asp:TextBox ID="TextBox3" runat="server" Text=""></asp:TextBox>
</td>

so far I am able to fix the issue with the upload and mapping but when I am having issues with the modification. When I modify/edit the data uploaded to the textboxes, only the straightforward textboxes get modified when I click SAVE, the rendered output textbox fields retrieve back to the original upload. This is my code behind:

protected void SaveClick(object sender, EventArgs e)
    {
            ....

            foreach (var categoryid in _categoryNAME)
            {
                if (categoryid.CategoryKindId == i)
                {
                    categoryNum = new qtrqsr();
                    categoryNum .yrqtr = new Currentqsr();

                    TextBox tb =FindControlRecursive(this.Master, "TextBox" + i) as TextBox;
                    if (tb != null & tb.Text.Trim().Length != 0)
                    {
                        categoryNum.CategoryKindId = i;
                        int dollarpos = tb.Text.Trim().ToString().IndexOf("$");
                        if (dollarpos == -1)
                        {
                            categoryNum.CategoryKindValue = String.IsNullOrEmpty(tb.Text.Trim().ToString()) ? null : (double?)Convert.ToDouble(tb.Text.Trim().ToString());
                        }
                        else
                        {
                            categoryNum.CategoryKindValue = String.IsNullOrEmpty(tb.Text.Trim().ToString()) ? null : (double?)Convert.ToDouble(double.Parse(tb.Text.Trim().ToString().Substring(dollarpos + 1)));
                        }                            
                        categoryNum.yrqtr.YrQtrID = QsrYId.ToString();
                        qsrcodes.Add(categoryNum);
                    }
                }
                i++;
            }

            business = new CurrentqsrBL();
            business.updateqsrprocess(currentqsr, qsrcodes);
            GetStQsr(QsrYrId);               

        }
        catch (Exception ex)
        {

            throw new ExceptionManager(ex);
        }

    }

Has anyone seen this behavior before, or know of a fix? I appreciate your time.

0

There are 0 answers