I'm having a problem displaying a Label control in a FormView which is within an UpdatePanel. The Label displays fine if the FormView is moved out of the UpdatePanel. I'm getting the error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. which I know is an Ajax error. I'm running Ajax 1.0 I see that quite a lot of people are experiencing the same error but so far none for the same reason as me.
FionaDM
Posts
-
Ajax error: problem displaying Label in UpdatePanel -
Problem with CompareValidator to compare TextBox control with Label controlI'm using CompareValidator to validate a TextBox control in FormView. I want to compare with a Label. I find however that when I select ControlToCompare, the Label isn't listed. The only controls to choose from are TextBoxes. And yes the Label does exist and is visible! Any ideas? Many Thanks Maj
-
Use CompareValidator to compare TextBox with LabelI'm using CompareValidator to validate a TextBox control in FormView. I want to compare with a Label. I find however that when I select ControlToCompare, the Label isn't listed. The only controls to choose from are TextBoxes. And yes the Label does exist and is visible! Any ideas? Many Thanks Maj
-
Prevent multple inserts after browser refresh?I'm not doing it within page load. I'm doing it with another event handler InsertRecord_Click. I've tried if not IsPostBack within that event i.e. if (!IsPostBack) { SqlDataSource1.Insert(); }; but IsPostBack always comes back false so the record never gets inserted. This strikes me as a common problem which lots of programmers must have encountered - or maybe they haven't noticed! I know that Dino Esposito has set out some advice on how to deal with this problem specifically at http://www.dotmugs.ch/events/event.aspx?eid=17 but I can't get on to it because I don't have a Swiss address. Thanks Majella
-
Prevent multple inserts after browser refresh?Each new record is inserted withn a unique id. The problem is that following insert if the user hits the browser refresh button the same record gets inserted albeit with a new id. How do I stop this happening? Thanks Majella
-
How to determine last event raised??Can anyone tell me how to determine the last event raised. E.g. If data has just been inserted using SqlDataSource1 I want to display some text in Page_Load. Something like if (SqlDataSource1_inserted == true) print message. Thanks Majella
-
ERROR! Two rows being deleted in gridview on delete.Help. When I hit the delete button to delete a row in gridview the required rows gets deleted but so also does the row following. I think I must be doing something very fundamentally wrong. Thanks Majella
-
How to access Query Designer in Microsoft SQL Server Management Studio?How do I access Query Designer from Microsoft SQL Server Management Studio? I mean the equivalent in SQL Server Enterprise Manager of Table -> Open Table -> Query I just can't find the equivalent from the menus. Also how to access DTS? Probably all very obvious! Thanks Majella
-
Pass value from dropdownlist to SQL select using SelectedIndexChanged?Thanks Majella
-
Pass value from dropdownlist to SQL select using SelectedIndexChanged?Thanks. Majella
-
Pass value from dropdownlist to SQL select using SelectedIndexChanged?I want to pass a(numerical) value from a dropdownlist to an SQL select using the DropDownList SelectedIndexChanged event. Here's my code so far. protected void MyDropDownList_SelectedIndexChanged(object sender, EventArgs e) { DropDownList MyDropDownList = (DropDownList)("MyDropDownList"); MyLabel.Text = MyDefinitionDropDownList.SelectedItem.Value.ToString(); string strSQL; strSQL = "SELECT COUNT(*) as count from MyTable where ID= ???"; } My problem is that I don't know what should replace the '???'. I've tried strSQL = "SELECT COUNT(*) as count from MyTable where ID= MyLabel.Text"; but this is interpreted as "SELECT COUNT(*) as count from MyTable where ID= MyLabel.Text" even though my debugger tells me MyLabel.Text is grabbing an OK value. If I do strSQL = "SELECT COUNT(*) as count from MyTable where ID= 6" for example it works fine. I think my problem is with casting? Thanks Majella
-
Pass value from dropdownlist to SQL select using SelectedIndexChanged?I want to pass a(numerical) value from a dropdownlist to an SQL select using the DropDownList SelectedIndexChanged event. Here's my code so far. protected void MyDropDownList_SelectedIndexChanged(object sender, EventArgs e) { DropDownList MyDropDownList = (DropDownList)("MyDropDownList"); MyLabel.Text = MyDefinitionDropDownList.SelectedItem.Value.ToString(); string strSQL; strSQL = "SELECT COUNT(*) as count from MyTable where ID= ???"; } My problem is that I don't know what should replace the '???'. I've tried strSQL = "SELECT COUNT(*) as count from MyTable where ID= MyLabel.Text"; but this is interpreted as "SELECT COUNT(*) as count from MyTable where ID= MyLabel.Text" even though my debugger tells me MyLabel.Text is grabbing an OK value. If I do strSQL = "SELECT COUNT(*) as count from MyTable where ID= 6" for example it works fine. I think my problem is with casting? Thanks Majella
-
Best data type for currency - asp.net & sql?What is the best way to define money such that sql server and asp.net agree? I have defined money in my sql tables as 'money' and values are stored with 4 places after the decimal point. In asp.net I'm using CompareValidator with DataTypeCheck of type 'currency'. This is raising a problem for me because asp.net permits only two places after the decimal point and throws up a validation error for money values i.e. because they have 4 places after the decimal point. I would like to define money as having 2 places after the decimal point. How can I achieve this? Thanks Majella
-
Pass DropDownList selected value to Label - FindControl problem?Thanks - I had omitted to specify the container (FormView1). Was DropDownList myDropDownList = (DropDownList)FindControl("DropDownList1"); but should have been DropDownList myDropDownList = (DropDownList)FormView1.FindControl("DropDownList1"); Many thanks Majella
-
Pass DropDownList selected value to Label - FindControl problem?I want to pass the value of the selected item in a dropdownlist to a label. The dropdownlist is inside a FormView and the label is outside in the main form. I'm trying to do this by implementing an event handler for the event OnSelectedIndexChanged. I cannot get it to work as I get an error: Object reference not set to an instance of an object w.r.t code: Label1.Text = myDDL.SelectedItem.Value.ToString(); Here's the ASP/HTML
... .... .... .... .... < ...
Here's the event handler (c#) protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { DropDownList myDropDownList = (DropDownList)FindControl("DropDownList1"); Label1.Text = myDropDownList.SelectedItem.Value.ToString(); } My FindControl clearly isn't doing what I think it should. I can get this to work if the dropdownlist is not inside a FormView where there is no need to use FindControl. E.g. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { Label1.Text = DropDownList1.SelectedItem.Value.ToString(); } But unfortunately I NEED to have the dropdownlist inside a FormView. Thanks Majella
-
How do I pass a gridview index to an sqldatasource select command?Thanks - that works great. I had a workaround assigning the index to a (hidden)label and then assigning the selected index value to the value of the label control. Your method is I think the best way! Thanks Maj
-
after succesfull insert1. Add a label to your page to output the success message. 2. Raise the FormView iteminserted event. 3. Write an event handler - something like : protected void FormView1_Inserted(Object sender, FormViewInsertedEventArgs e) { // Hide the formview FormView1.Visible=false; Label1.text="Record successfully inserted"; } Remember too you can hide the Label to begin with within Properties. I find the visible attribute very useful. You might also like to look at the example at http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.formview.iteminserted.aspx Hope this helps. Maj
-
How do I pass a gridview index to an sqldatasource select command?How do I pass a gridview index, as calculated by gridview RowCommand, to an sqldatasource select command? My code is appended. I have a gridview with a Buttonfield with Commandname 'SelectStaff'. On SelectStaff I want to calculate the index of the current row. I have done this successfully using Gridview OnRowCommand event. See method GridView1_RowCommand. I then want to pass the calulated index to the an SqldataSource select command so I can populate a FormView with data whose index is the same as the gridview index. I'm trying to use the Sqldatasource Selectingevent to pick up the index value but with no success. See method SqlDataSource2_Selecting. P.S. I can't use the the GridView CommandField Select as it's already been used. Here's my code: ID:
Name:
private int index = 0; protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "SelectStaff") { // Convert the row index stored in the CommandArgument // property to an Integer. int index = Convert.ToInt32 -
how to use items in a formviewI can only imagine it's to avoid ambiguity. For example imagine FormView1 and FormView2 on the same page both with labels with ids of 'label01'. You couldn't access either without specifying which FormView you were targeting. Maj
-
how to use items in a formviewYou need to use FindControl for this. Try: protected void Button1_Click(object sender, EventArgs e) { Label MyLabel = null; MyLabel = (Label)FormView1.FindControl("label01"); MyLabel.Text= "xxxx"; } I'm just learning this stuff so it may not be the nicest way - but it should work. Maj