Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8652559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:20:06+00:00 2026-06-12T14:20:06+00:00

Ok so what seems like a basic problem is getting the better of me

  • 0

Ok so what seems like a basic problem is getting the better of me and my exstensive google efforts have come up short. Perhaps I don’t understand enough to ask the right questions.

Here’s my problem:

I have a formview control, or rather a series of them, each page displaying entry from previous forms, for a higher level access to approve/edit as needed. So, on form “B”, I have the contents of form “A” and the blank part of “B” to filled out…So two seperate fromviews on the page..”A” and “B”

That works fine, the issue is when I change the mode to edit previous entry. So if I have a button or the default linkbutton to change from ReadOnly to Edit I not only lose bindings but any efforts to counteract that have left me with issues when I postback.

DUE TO LENGTH I’M LEAVING SOME CODE OUT

On my button I’m using FormView2.ChangeMode(FormViewMode.Edit) to change view, the default link button I’ve not changed

Bindings on my listboxes are setup like:

If Not Page.IsPostBack Then
    'pulling bindings from table
    cmd = New OleDbCommand("SELECT * FROM mslToi", objCon)
    objReader = cmd.ExecuteReader
    lst1.DataValueField = "listing"
    lst1.DataTextField = "listing"
    lst1.DataSource = objReader
    lst1.DataBind()

    'pre-selecting input data from form "A"
    cmd = New OleDbCommand("SELECT [type_of_injury] FROM S2childToi WHERE ID = " & qs & "", objCon)
    objReader = cmd.ExecuteReader
        Do While objReader.Read

            For Each y As ListItem In lst1.Items
                If y.Text = objReader.Item(0) Then
                    y.Selected = True
                End If
            Next
        Loop

end if

In the page load event.

MARKUP FOR THE FORMVIEW AS ASKED

<asp:FormView ID="FormView2" runat="server" 
    Width="100%" DataSourceID="AccessDataSource4">

<ItemTemplate>
</ItemTemplate>

<EditItemTemplate>
</EditItemTemplate>

</asp:FormView>

”’that is the short and sweet of the formview markup as requested. It may also be worth noting that it doesn’t matter what mode I start in, if I change modes it equals same result”’

That works fine so far…it’s when I change view to Edit that my listbox appears to no longer be bound (controls appear but have no content). My thought is that obviously I’m blocking out my code from postback events (I have a reason for this). I can use this code (without the If Not Page.IsPostBack) to force the selections and bindings but whenever I postback they will defualt to the table data, which can’t happen, each listbox needs to postback so I can check for a certain selection. So what happens is the user input is trumped. Short and sweet.

I’m sorry that I can’t explain better, any advice is much appreciated. If I can asnwer any questions or post code let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:20:07+00:00Added an answer on June 12, 2026 at 2:20 pm

    Try this:

    <asp:FormView ID="FormView1" runat="server">
        <ItemTemplate>
            <asp:ListBox ID="ListBoxReadonly" runat="server"></asp:ListBox>
        </ItemTemplate>
        <EditItemTemplate>
            <asp:ListBox ID="ListBoxEdit" runat="server"></asp:ListBox>
        </EditItemTemplate>
    </asp:FormView>
    

    Then, in your FormView’s databound event, bind the data into your listbox depending on the current view.

    Protected Sub FormView1_DataBound(sender As Object, e As EventArgs) Handles FormView1.DataBound
        Dim myListBox As ListBox
    
        If FormView1.CurrentMode = FormViewMode.ReadOnly Then
            myListBox = DirectCast(FormView1.FindControl("ListBoxReadonly"), ListBox)
        ElseIf FormView1.CurrentMode = FormViewMode.Edit Then
            myListBox = DirectCast(FormView1.FindControl("ListBoxEdit"), ListBox)
        End If
    
        If myListBox IsNot Nothing Then
            myListBox.DataValueField = "listing"
            myListBox.DataTextField = "listing"
            myListBox.DataSource = GetListingData()
            myListBox.DataBind()
    
            ' your pre-select code here...
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a very basic problem but I can't figure it out. I'm
I'm having some issue getting what seems like a fairly straight-forward problem solved in
This seems like a basic question, but I haven't found any clear answers. Essentially,
This seems like a basic question, but it's still bugging me. Why doesn't MyObject
This may seem like a basic question. I have a light-weight website and would
Seems like i need some help with a project. I have a routine ,
Seems like cuke doesn't show the full error message (at least when problem occurs
I have tried the basic ones found in a Google search and even tried
Hi I am having problem while matching Kohana 3 custom route, it seems like
I have a problem using the display: table features of CSS. I am getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.