Solved

Insert textboxes values from repeater into database

Posted on 2006-10-30
6
416 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to go to Web page 2 93
Trying to use colormap to replace color in png, with a gradient to transparent 7 31
error on the asp.net page 1 33
Name space syntax error 12 39
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

914 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

12 Experts available now in Live!

Get 1:1 Help Now