Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When does datasource reissue a select
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01325539
Message ID:
01327102
Views:
16
>>>>I found the answer. See http://www.theproblemsolver.nl/dotnet_faq_0013.htm. It seems that the .NET framework has a quirk that the listbox is populated after a postback from the viewstate. Therefore if the value is not in the listbox when the postback occurs, it will not be there after the postback either. The solution is to add it explicitly before the postback occurs.
>>>
>>>
>>>That's not a quirk.
>>>
>>>Thats a bug.
>>
>>
>>I tend to agree but since I am a total newbie to .NET I wanted to be careful in my condemnation. I have found lots of things in .NET webforms that look and act like kindergarden compared to VFP. I really don't understand M$ when they have a great product like VFP and then try to replace it with something newer and worse.
>>
>
>I'd say it's neither if you understand why it's doing what it's doing. You'll run into this a lot with web applications under ASP.NET and viewstate. In some respects you can think of the viewstate as simply a client-side cache. Instead of it repopulating the list by hitting the database (which can be fairly expensive in time), it does it via a serialized representation of the data at the time the control was rendered (then deserializes it back on the server at postback). You don't need to hit the database everytime the page posts back (remember - the web is stateless; these controls need to be rebuilt on every postback). There's more to it than that, but this is one aspect of what it's used for). Sometimes the effect of this isn't quite what you want or expect, but it's baked into the design (you might curse it here but in other places it's what is making things "just sort of work like a desktop app").
>
>You also can't really compare a web application to a desktop application. They are fundamentally different beasts, with different design constraints.

Ahh yes, I understand all that at least on a superficial level. But you would think there would be a way to force the database to be requeried and the controls to be refreshed when that is necessary. But so far at least I have not found the secret to doing that. Case in point, the page contains a datalist bound to SQLDatasource, the underlying table gets a new record but upon the postback the datalist goes completely blank. Do you know how to deal with this?
Protected Sub cmdAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
        Dim sql As String = "INSERT into list_members (list_ID, personID, subgroup1) VALUES "
        sql += "(" & Session("CurrentList").ToString & "," & ListBox2.SelectedValue.ToString & ",'Member')"
        SqlDataSource3.InsertCommand = sql
        SqlDataSource3.Insert()

        DataList1.DataBind()

    End Sub
Another example, the listbox only supports 1 column and a value. As long as they were redefining the control why not give it multi column cababilities as in VFP? Searching the web it seems like there is plenty of desire for this feature, and others who are more brilliant than I have figured out various work arounds, but why not just build it in?
Previous
Reply
Map
View

Click here to load this message in the networking platform