C# Find Text Boxes Grab Data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karenRoss
    New Member
    • Jun 2007
    • 27

    C# Find Text Boxes Grab Data

    Hi!

    Okay, here's the issue:

    I have a nested repeater with this:
    <td width="125px">< input type="text" name="M<%# DataBinder.Eval (Container.Data Item, "combos_id" ) %>" size="10" maxlength="10"> </td>
    <td width="350px">< input type="text" name="C<%# DataBinder.Eval (Container.Data Item, "combos_id" ) %>" size="50" maxlength="100" ></td>

    I need to search the page, find all the text boxes and get their values. However, I don't know anything about the ID other than it starts with a C or an M. I can't get a count from my initial data, so I query again to get the number of text boxes possible.

    Even with a loop I cannot seem to actually "find" the objects. Any thoughts on any way to do this at all? foreach?
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Originally posted by karenRoss
    Hi!

    Okay, here's the issue:

    I have a nested repeater with this:
    <td width="125px">< input type="text" name="M<%# DataBinder.Eval (Container.Data Item, "combos_id" ) %>" size="10" maxlength="10"> </td>
    <td width="350px">< input type="text" name="C<%# DataBinder.Eval (Container.Data Item, "combos_id" ) %>" size="50" maxlength="100" ></td>

    I need to search the page, find all the text boxes and get their values. However, I don't know anything about the ID other than it starts with a C or an M. I can't get a count from my initial data, so I query again to get the number of text boxes possible.

    Even with a loop I cannot seem to actually "find" the objects. Any thoughts on any way to do this at all? foreach?
    Hi karen,
    what you have to do is get a list of all controls by this.controls, and check if they are a input type (if you can use asp .net controls it would be easier i suppose)

    also refer to this site:

    Comment

    • shiponeye1
      New Member
      • Aug 2007
      • 8

      #3
      Originally posted by karenRoss
      Hi!

      Okay, here's the issue:

      I have a nested repeater with this:
      <td width="125px">< input type="text" name="M<%# DataBinder.Eval (Container.Data Item, "combos_id" ) %>" size="10" maxlength="10"> </td>
      <td width="350px">< input type="text" name="C<%# DataBinder.Eval (Container.Data Item, "combos_id" ) %>" size="50" maxlength="100" ></td>

      I need to search the page, find all the text boxes and get their values. However, I don't know anything about the ID other than it starts with a C or an M. I can't get a count from my initial data, so I query again to get the number of text boxes possible.

      Even with a loop I cannot seem to actually "find" the objects. Any thoughts on any way to do this at all? foreach?
      HI KAREN,
      to get all the controls within a form, u can use

      Controls oFormControls=t his.Controls;
      it returns all the controls on the form. but it better if u put all the textbox in groupbox or panel. then it'll iterate throw few controls.

      //this code iterate throw all controls on the form
      foreach (Control ctl in this.Controls)
      {
      if(ctl.GetType( ).Name== "TextBox")
      {
      if(ctl.Name="tx tName")
      string sName=ctl.Text;
      }
      }

      //this code iterate throw all controls on the grpTextBox of the form

      foreach (Control ctl in this.grpTextBox .Controls)
      {
      if(ctl.GetType( ).Name== "TextBox")
      {
      if(ctl.Name="tx tName")
      string sName=ctl.Text;
      //do something
      }
      }


      i think it resolve ur problem. if not or u want to know more about it, mail me to
      [email removed]

      !!! SHIPON !!!
      Last edited by MMcCarthy; Sep 2 '07, 11:27 AM. Reason: email removed - against site rules

      Comment

      Working...