Solved

Insert textboxes values from repeater into database

Posted on 2006-10-30
6
402 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
  • 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now