Solved

Insert textboxes values from repeater into database

Posted on 2006-10-30
6
442 Views
Last Modified: 2008-03-06
I have a repeater, that repeats over a textbox. I am trying to insert the values of all 4 textboxes into the database.

 <asp:Repeater ID="rpComp" runat="server">
                        <HeaderTemplate>
                        <table>                      
                       
                        </HeaderTemplate>
                            <ItemTemplate>
                            <tr>
                            <td>
                                <%#Eval("Course")%>
                            </td>
                            <td>
                                <asp:TextBox ID="txtQuestion3" runat="server" Width="25"></asp:TextBox>
                            </td>
                            </tr>
                            </ItemTemplate>
                            <FooterTemplate>                          
                            </table>
                            </FooterTemplate>
                        </asp:Repeater>  

I have to be able to insert the data something like this...
srBll.SaveResultsToDatabase(tb1, tb2, tb3, tb4)
0
Comment
Question by:JRockFL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:jeebukarthikeyan
ID: 17833982
hi,

TextBox txt;
                  for( int i=0;i<Repeater1.Items.Count;i++)
                  {
                        txt=(TextBox)Repeater1.Items[0].FindControl("txtQuestion3");
                        Response.Write( txt.Text);
                  }

b u d d h a
0
 
LVL 13

Accepted Solution

by:
jeebukarthikeyan earned 500 total points
ID: 17834014
hi,

              TextBox txt;
              TextBox txt1;

               for( int i=0;i<Repeater1.Items.Count;i++)
               {
                    txt=(TextBox)Repeater1.Items[0].FindControl("txtQuestion3");
                    txt1=(TextBox)Repeater1.Items[0].FindControl("txtQuestion3");
                    ........
                    srBll.SaveResultsToDatabase(tb1, tb2, tb3, tb4)
               }

b u d d h a
0
 
LVL 8

Author Comment

by:JRockFL
ID: 17834019
Thanks for your reply, but I need to be able to insert all of the values into the database, by passing 4 values to my saveresults sub.

For example..
srBll.SaveResultsToDatabase(tb1, tb2, tb3, tb4)

Is it possible to create 4 variables and set the values?
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 13

Expert Comment

by:jeebukarthikeyan
ID: 17834089
hi,

just think if ur repeater is like this

  <asp:repeater id="Repeater1" runat="server">
  <ItemTemplate>
    <asp:TextBox ID="txtQuestion1" Runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.name") %>'>      
    </asp:TextBox>
    <asp:TextBox ID="txtQuestion2" Runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.name") %>'>      
    </asp:TextBox>
   <asp:TextBox ID="txtQuestion3" Runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.name") %>'>      
    </asp:TextBox>
  </ItemTemplate>
  </asp:repeater>

  code behind

  TextBox txt1;
  TextBox txt2;
  TextBox txt3;
  for( int i=0;i<Repeater1.Items.Count;i++)
  {
    txt1 = (TextBox)Repeater1.Items[0].FindControl("txtQuestion1");
    txt2 = (TextBox)Repeater1.Items[0].FindControl("txtQuestion2");
    txt3 = (TextBox)Repeater1.Items[0].FindControl("txtQuestion3");

    srBll.SaveResultsToDatabase(txt1.Text , txt2.Text , txt3.Text)
  }

  b u d d h a
0
 
LVL 8

Author Comment

by:JRockFL
ID: 17836221
thank you very much! that is what i needed.
0
 
LVL 8

Author Comment

by:JRockFL
ID: 17872883
What about finding the control if the textbox is in the footer?

                            <FooterTemplate>
                            <tr>
                            <td>Other courses</td>
                            <td><asp:TextBox ID="txtOtherCourses" runat="server" Width="25" onFocus="startCalc();" onBlur="stopCalc();"></asp:TextBox>%</td>
                            </tr>
                            </table>
                            </FooterTemplate>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expression Evaluater 3 46
Function after success of Jquery/AJAX action 9 45
locate sql commands in C# visual studio Project 6 44
orderby list (from Json) 1 30
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question