Solved

Insert textboxes values from repeater into database

Posted on 2006-10-30
6
450 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
Technology Partners: 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!

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

623 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