display database values in textboxes and pass parameter in response.redirect

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Surag
    New Member
    • Sep 2010
    • 3

    display database values in textboxes and pass parameter in response.redirect

    Hello Guys,

    I have a datbase with userid,username and password.
    I Need to display database values in textboxes say for eg(Name and password) and redirect to login page based on the UserID please need a help

    Thanks
    Surag
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    I'm not sure what you're having problems with?

    To display text in a TextBox set the TextBox.Text property to the text that you want to display.

    To pass values from one page to another you could use Session, or you could pass the information via the URL during the redirect. I wouldn't recommend using the URL though because you're dealing with password information...w ell unless you passed the UserID via the URL and retrieved the password based on that value in the page that you are redirecting to.

    Please elaborate on what you are trying to do and what you have done so far to solve the problem.

    -Frinny

    Comment

    • Surag
      New Member
      • Sep 2010
      • 3

      #3
      Hi,
      Thanks for replying me!!
      am listing you with detail ,am using repeater control and displaying database values and even able to delete the selected values!!
      want i want to do is once if any user selects any record from repeater control and clicks add button the selected record should be inserted in the user table followed wth the selected items id!!

      so i need to redirect frm my login page to rptr control page and select any item from repeater control(using check box) and click add button so tht it will add to my tble!!
      i even tried using sessions but am unable to do it please help me out

      Thanks
      surag

      Comment

      • mzmishra
        Recognized Expert Contributor
        • Aug 2007
        • 390

        #4
        Try something like this
        Code:
        foreach (RepeaterItem dataItem in RepeaterName.Items)
        {
        CheckBox chk =(CheckBox)dataItem.FindControl("yourcheckboxname") ;
        
        TextBox txt =(TextBox)dataItem.FindControl("yourTextboxname"); 
        if (chk.Checked)
        {
        
        DoInsert(txt.Text);
        }
        }
        I have assumed you are displaying data in textbox inside repeater.You can use the above code for your control

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Originally posted by surag
          surag: I am using repeater control and displaying database values and ...
          want i want to do is once if any user selects any record from repeater control and clicks add button the selected record should be inserted in the user table followed wth the selected items id!!
          Inserted where?
          Where is the user table?

          Are you retrieving data from one table in your database, and adding these records (if selected) to another table in the database?

          Or are you retrieving data from your database, and then when the user clicks the "add" button, you want to add this record to a table (in memory) that is simply displayed to the user (not added to the database)?

          Originally posted by surag
          surag: so i need to redirect from my login page to repeater control page and select any item from repeater control(using check box) and click add button so tht it will add to my tble!!
          I really don't understand how redirecting ties into the "add-record" part of your question.

          Typically a user logs in and they are redirected into the website (allowed access to the rest of the pages in the site).

          Why do you have to redirect the user once the add-button is clicked??

          -Frinny

          Comment

          • Surag
            New Member
            • Sep 2010
            • 3

            #6
            hi Frinny,
            thnaks for replying me,and
            Thanks for ur patience! i thnk i confused u, oops!!sorry, let me eloborate wth examples:
            in sql database i have 3 tables

            Usertable: UserID,Uname,PW d
            ContentTable: ContentID,Conte ntname
            COmmontabel-UserID: ContentID(this is crucial)
            (storing userid,and contentid i thnk u got my poin here)

            now cmmng to .aspx pages
            i have default.aspx with login control,
            once user click on login (in databse checks for username and password if usernme and pwd are same )
            and redirects to home.aspx

            in home.aspx i have got repeater control which displays all the (contenttable data) and addbutton

            so when user checks "check box" in repeater control and clicks "addbutton" based on his UserId(wth wch he login)
            data should be inserted into Commontable(i.e UserId,ContentI D)
            Hpe u understand this time :(

            Thanks
            surag
            Last edited by Frinavale; Sep 9 '10, 04:26 PM.

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Ah now I understand.

              Ok, when the user logs in, save the user's ID in Session before you redirect them to the home.aspx page.

              Then in the home.aspx page you can retrieve the user's ID from session (if it's not there then you know the user is not logged in and you can redirect the user back to the default.aspx page).

              You should probably retrieve the User's ID from Session in the Page Load event, check if it's nothing...and if it is nothing redirect the user back to the default.aspx page. Otherwise, you can allow the rest of the page to execute properly.

              So, now that I understand the general flow of the, what are you having problems with exactly?

              Are you having problems handling the "AddButton" click event?

              Are you having problems with database stuff??

              It would probably be best if you posted the code that you are having problems with so that we can work with what you have (at this point I'm not even sure if you're using C# or VB.NET)

              -Frinny

              Comment

              • jagdeep gupta
                New Member
                • Aug 2010
                • 98

                #8
                how to handle button click event at here
                as there are so many buttons but a common function has to be written

                Comment

                Working...