I am using an update panel and when I click a button it will update all the panels.
updapanel1.update() is very simple, but my data is not updating unless I hit the button twice.
My gridviews shows data for a selected user, and then all the grids reflect that users data.
works fine all the update panels work for the gridviews.
Now for somereason when i try to do a row count and update the panel with the summary, it does not work, i get either the previous users summary or if i hit update again for the same user i get the correct data.
'the grids are in these panels
UpdatePanel1.Update()
UpdatePanel2.Update()
UpdatePanel4.Update()
UpdatePanel6.Update()
UpdatePanel7.Update()
'the things that are not updateing correctly
rqnum.Text = GridView3.Rows.Count
oknum.Text = GridView4.Rows.Count
xlnum.Text = GridView5.Rows.Count
dynum.Text = DataList1.Items.Count
UpdatePanel8.Update()
Panel1.Visible = False
Without seeing the code for this we cannot guarantee that we are giving you the right answer, but just a thought. If the code you posted is the actual code, I would re-order things a bit.
Do the updates to the content
Then call "update" on the panels
This ensures that your content updates are actually sent to the panels. My guess is this is why it takes that second click. So something like this.
'Update content and toggle visibility of controls
rqnum.Text = GridView3.Rows.Count
oknum.Text = GridView4.Rows.Count
xlnum.Text = GridView5.Rows.Count
dynum.Text = DataList1.Items.Count
Panel1.Visible = False
'Now update all needed panels
UpdatePanel1.Update()
UpdatePanel2.Update()
UpdatePanel4.Update()
UpdatePanel6.Update()
UpdatePanel7.Update()
UpdatePanel8.Update()
Related
When I create new record in Google AppMaker and then try to add correlated record to this new one I get this warning in console:
com.google.apps.appmaker.client.datasource.AbstractModelDataSource
WARNING: Could not find element with key RecordKey{key=private$7,
model key=...
Both datasources are set to:
Manual save mode
Automatically load data
The problem doesn't appear when I refresh the page or try to add correlated record to other existing record.
Anybody knows what could be a reason for this error?
App Maker doesn't allow to have unsaved changes on both ends of relation, most likely it is a reason, why you recieve error message in the first case. But in theory it should work once you save one of the relation ends (first save one of the records and then link them and save again):
var countryDs = app.datasources.Country;
var capitalDs = app.datasources.Capital;
countryDs.createItem();
countryDs.item.Name = 'United States';
countryDs.saveChanges(function() {
capitalDs.createItem();
capitalDs.item.Name = 'Washington, D.C.';
capitalDs.item.Country = countryDs.item;
capitalDs.saveChanges();
});
OK, I fixed it.
I have two forms. First to create item. Second to edit data. In the first form page need to be set to:
On Detach: Clear Changes To Datasource.
Datasources need to be set to autosave.
I have a panel Profiles List on a web page. It contains multiple small panels, like a list of items contains lines. The items here are profiles. Each profile is actually a small panel SingleProfile with checkbox inside. Checkbox is the core here, because it has an ID, which is used to find the same items.
On this page there is also another similar big panel. I should add to the second panel only those items, which do not exist in the first one. So, the task is to show in the second panel only those profiles, which are not presented in the first panel. This is checked using IDs of the checkboxes in both lists.
To check if a newly added profile in the second panel already exists in the first panel, I try to access the ID property of each item in the first panel through Controls[] property. I do it in the cycle:
if (ProfilesPanel1.Controls.Count > 0)
{
for (int i = 0; i <= ProfilesPanel1List.Controls.Count - 1; i++)
{
//label1.Text += " "+Convert.ToString(sqlReader["chain_id"]); //Bug #2 - see Stored Procedure description
cbx1 = new CheckBox();
cbx1 = (CheckBox)ProfilesPanel1List.Controls[i].Controls[1]; //Bug #1 - here the Exception occurs
if (cbx1.ID == Convert.ToString(sqlReader["chain_id"])) //if profile already exists in the first panel
{
//Do not add this profile to the second panel
}
}
}
The exception "System.ArgumentOutOfRangeException" occurs in the line marked with "Bug #1".
I use sqlReader which takes IDs from a stored procedure. Stored procedure works fine in the Sql Server. But, when I output values of the sqlReader into a label on a web page (see comments in the code), each value is doubled, like "1 1 2 2 3 3 4 4 5 5".
Solution to BUG #1
Check number of controls and its names from quickwatch in debug mode and see, is ProfilesPanel1List.Controls[i] a panel or some other control. Choose your index correctly after checking it in debug mode.
And also you don't need to use cbx1 = new CheckBox(); line of code. Its next line of code is enough to initialize that Checkbox.
Your sqlReader code is not enough to get the actual cause of 2nd error.
For Bug#1, there is a chance that there might be no nested controls existing underneath 'Controls[i]'. So to guard against the bug, you can first check if there are any nested controls underneath the current element and then checking the type of control before type casting.
if(ProfilesPanel1List.Controls[i].Controls.Count>1 && ProfilesPanel1List.Controls[i].Controls[1] is CheckBox) //Iff you are double sure about layout structure and assured that it is not going to
//change. If changes are anticipated then again doing a foreach(..) over nested 'Controls' and type
//checking is much better.
{
//Do the type conversion etc., as per your requirement.
}
For Bug#2, what do you exactly mean by 'each value is doubled'? As I can see that you are appending to the same Label (with ID: Label1) inside the loop so, there is a chance for the text to be concatenated on every iteration. Also, please be sure as per your requirement, whether you need to manipulate same label's text or label inside nested controls of the parent panel.
I'm working on a web application where a user can order a custom portrait drawings by making choices from a variety of radio button lists. There is an extra charge if they want multiple people in the portrait, so one of the questions is whether or not there will be an additional person. They can select either "Yes" or "No" from a radio button list (the choices are currently in that order, with Yes at index 0 and No at index 1). If the user selects No, nothing happens and they move on to the next question. But if they click yes, a text box whose Visible property is currently set to False appears and they enter the number of additional people.
The problem is that I can't get my text box to become visible. I currently have my TextBox.Visible = True line of code under the radio button list's SelectedIndexChanged event handler. Here's the whole subroutine:
Protected Sub RadioButtonListAdditional_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles RadioButtonListAdditional.SelectedIndexChanged
Dim characters As Integer
If RadioButtonListAdditional.SelectedIndex = 0 Then
txtAdditionalChars.Visible = True
characters = CInt(txtAdditionalChars.Text)
additionalprice = characters * 5
ElseIf RadioButtonListAdditional.SelectedIndex = 1 Then
additionalprice = 0
End If
End Sub
additionalprice was declared earlier. The rest of that just has to do with the pricing scale for the additional characters. Anyway, I feel like I'm really close to having it right and that I'm just missing something small - my VB is a little bit rusty. Any suggestions?
Have you set AutoPostBack = True on your RadioButtonListAdditional object?
Or you may need to check whether you have code on Page_Load event that call
txtAdditionalChars.Visible = False
Please let me know if this helps
In VB Net .. Radiobutton control ..
Do it in your Radiobutton CheckedChanged event .. something like this
if rb.Checked then txtbox.Visible = True
I am using ReportViewer.WebForms in asp.net page. I have the parameter toolbar showing up where I can select a parameter, it does a postback to get the next parameter (dependent on the first), and so forth.
When I click the View Report button there is a postback and the report will display fine.
All this works great.
What I would like to do is set the ShowReportBody to false
ReportViewer.ShowReportBody = False
At this point I would like to grab all the parameters that have been selected by the user and run the render method to export to a file (of my choosing .. maybe excel, maybe pdf .. does not really matter, nor is the topic of this question).
So, my question is, how (or can I) trap the button event of the View Report button? I would like to be able to use the ReportViewer UI in order to capture all the parameters instead of building custom parameters.
I'd also like to rename this, but, again .. another topic :)
You can use the IsPostBack flag and QueryString
Example:
Viewer.ShowReportBody = false
if(IsPostBack)
{
if(Request.QueryString["Exec"] = "Auto")
Viewer.ShowReportBody = true;
...
}
else
{
Viewer.ShowReportBody = true;
}
I'm still fairly new to ASP.Net, so forgive me if this is a stupid question.
On page load I'm displaying a progress meter after which I do a post back in order to handle the actual loading of the page. During the post back, based on certain criteria I'm disabling certain links on the page. However, the links won't disable. I noticed that if I force the links to disable the first time in (through debug) that the links disable just fine. However, I don't have the data I need at that time in order to make the decision to disable.
Code Behind
If (Not IsCallback) Then
pnlLoading.Visible = True
pnlQuote1.Visible = False
Else
pnlLoading.Visible = False
pnlQuote1.Visible = True
<Load data from DB and web service>
<Build page>
If (<Some Criteria>) Then
somelink.Disable = True
End If
End If
JavaScript
if (document.getElementById('pnlQuote1') === null) {
ob_post.post(null, 'PerformRating', ratingResult);
}
ob_post.post is an obout js function that does a normal postback and then follows up with a call to the server method named by the second param. then followed by the call to a JavaScript method named by the third param. The first parameter is the page to post back to. A value of null posts back to the current page.
The post back is working fine. All methods are called in the correct order. The code that gives me trouble is under the code behind in bold. (somelink.disabled = True does not actually disable the link) Again, if I debug and force the disabling of the link to happen the first time in, it disables. Does anyone know what I might do to get around this?
Thanks,
GRB
Your code example is using the IsCallBack check, while the question text talks about the IsPostback Check. I'd verify that you're using Page.IsPostBack in your code to turn off the links.