0

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.

Scath
  • 3,777
  • 10
  • 29
  • 40
Geezus
  • 39
  • 3
  • 11
  • Is `tb` null after it tries to find TextBox1, 2 and 3? – Jim W Mar 22 '18 at 20:43
  • @JimW I honestly cannot tell if it is null or not, I am very new to programming. But when I put a breakpoint and I ran it again, tb has ID = TextBox188. Which is weird because I only edited TextBox1 while dedubbing – Geezus Mar 22 '18 at 21:08
  • I'm not really clear on your loop, and what data is in `_categoryNAME`. Or how you're incrementing `i`, and how that pertains to the values in `_categoryNAME`. I think you should simplify your code a lot in order to understand what is happening (I mean keep the code you have but write new code that simply investigates the values of the textboxes) - I'd wager the problem is not where you think it is. – Jim W Mar 22 '18 at 22:32

0 Answers0