Web Forms :: Error - Dropdown Control Index Automatically Set To 1
Jul 19, 2010
I have an asp.net project and my problem is that whenever i have select the dropdown control to an item then it automatically set to the index 1. I have debugged a more and couldnot found any reason for this. I have set the autopost back property of the dropdown to false and checked again, but nothing happend.
I am having a label to show success message during the successfully save.
I am having a drop down with the name "Technology".
During on selected index change event of the drop down, i am binding another drop down with the name "Resources".
When the Button is clicked, i am showing the "success message" and on click event of the drop down, i am clearing the message by using the java script.
function ClearErrorMessage() { document.getElementById('ctl00_ContentPlaceHolder1_lblMessage').innerHTML = ''; }
But when i change the drop down, the message gets reappeared.
I have already stored value of author id in list item value while page loads. but when I change index of drop down list to view author information error is shown. I tried to debug using check points and it seems Sqlreader isn't reading database second time.
I wonder if there is a clevcer way of setting the correct page of a DetailsView after inserting new data? I have a DetailsView bound to a LinqDataSoure. Now, if I use this DetailsView to insert new data, everything works fine, except the fact that the DetailsView switches back to the "old" page index after leaving InsertMode.
This is somehow understandable, because it can't know which index the new entry will have, but unfortunately neither do I. So I was looking to the LinqDataSource_Inserted event where I can get the new Entry, but because the DetailsView.SelectedValue is read only, I can't just set it to the new entry. So. I might have to use the PageIndex property, but then I would need to know the index of the new Item, which I don't have either.
So, my only idea know is to store some information from the new entry, wait until everythings bound again, loop through the DetailsView to find my new entry an set it's index for PageIndex. But also here I have two problems:
1) The new entry (e.Result from LinqDataSource_Inserted) has not yet filled it's primary key, as this is of course created in the DB, so it's very difficult to identify the new entry properly 2) I don't know how to access each DetailsView page information without actually making it the active page.
So, my question, is there a clever way of doing this? In the past, I've been using SqlDataSource. Although the problem is basically the same, I could solve the two major problems by 1) Insert with Stored procedure which gives the new primary key back and 2) run through
I have a simple application with a GridView bound to a LinqDataSource and a DetailView that displays a row from the GridView when it's selected. This works as expected. But now I'm placing the GridView and DetailView in separate TabPanels in an asp.net ajax Tab Control.
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index] System.Collections.ArrayList.get_Item(Int32 index) +7483656 System.Web.UI.WebControls.GridViewRowCollection.get_Item(Int32 index) +13 _Default.Results_SelectedIndexChanged(Object sender, EventArgs e) in c:Documents and SettingsAdministratorMy DocumentsVisual Studio 2008WebSitesWebSite1Default.aspx.cs:35
The line of code getting the error is the one attempting to get the SelectedIndex from the GridView and update my DetailView. GridViewRow row = Results.Rows[Results.SelectedIndex]; I stepped through the code with the debugger and SelectedIndex is not negative and it's not larger than the number of rows in the GridView. So I'm confused why simply placing the controls inside a Tab is causing this error?
Cannot create the clustered index 'RateViewIndex' on view 'NoteToPass.dbo.RateView' because the select list of the view contains an expression on result of aggregate function or grouping column. Consider removing expression on result of aggregate function or grouping column from select list.
-the first one bound to a sqldatasource and it's work fine
-the second one bound to a sqldatasource (with a parameter depends on the first drop down list selected value )and it's work fine too .
But when a user make a selection on the second drop down list, any post back on the page will return the second drop down list selected index equal to 0.I tried so hard (ON MSDN) to understand why this happen only on this drop down list.
I'm trying to follow this article on cascading dropdown list in a GridView control in edit mode (except I'm using C#) [URL] I keep getting this error message "ProjectID is neither a DataColumn nor a DataRelation for table DefaultView."
i have two dropdownlist, second dropdown populates based on value selected in first dropdown.
Parentdropdown is working fine and second dropdown is also popualting correctly. But when i select value from second dropdown and click on submit button it resets to first value i.e though i have chosen 3rd value from dropdown it resets to first value.This happens when autopostback is not thr.
If for the same case ifi do autopostback=true. It chnages to first value automatically . then it odesnot require submitbutton click as well.
In both cases selected index is not getting set for second dropdown.
I created my page with asp dropdown. On selected index changed I am seeing postback operation on dropdown. I couldn't avoid postback operation of asp dropdown with updatepanel also.
IS there a another way to avoid dropdownpostback operation.
I have a dropdown binded with database value Eg : A001, A002, A003 etc. When ever i use to select the first value A001 , it is not going for postback. After selecting the second index value A002 n then selecting the first value A001 , i use to post back. And i dnt want to use appent data bound here.
We are developing our application on a 64 bit server. We are using a dropdownlist to filter and display departments in a htmltable(hide and show rows) on every selectedindexchanged event.
The issue is it is firing properly for the first time, but it is not doing a post back there after. We have even given autopostback=true. We are using AJAX for hiding and showing the rows of the htmltable.
I am developing page for maintaing employee record using Visual Studio 2008, MS SQL server 2005. I am able to fetch and display all the employee information in gridview, the gridview have the dropdown list to display the employee type [ Part Time, Full Time, Permanent , Contract ], in the item template i am having dropdown list. IN the dropdown list i am displaying this. But While saving the record in gridview the droppdown selected index are changed to 0 of other dropdown list.
the user may be change the dropdown value from permanent to contract, or so. but while click on the save button in gridview, all the previous selection are gone, and always showing the first record of dropdown list. I know this is happening because we are doing dropdown list bind on onRowDataBound.
I have a details view control which contains a dropdown list.
I would like to update a row in the DV based on when the selected index change event occurs in another row of the
So far I know that 1) Place code in detailsview1.rowupdating event .
2) Make a row copy, not sure about the syntax here
Dim aRow As DetailsViewRow = Me.DetailsView1.Rows(DetailsView1.Rows.Item(?)) 3) Find my DDL Dim aDDL as dropdownlist = CType(aDDL.cells(?).Findcontrol("Dropdownlist3"0, dropdownlist) If aDLL.selected IndexChanged then Dim aTextbox as textbox = Ctype(detaislview.cells(?).findcontrol("Textbox6", textbox6) aTextbox.text = now()
create List of dynamic asp:Label, asp:textbox and asp:button when asp:dropdown selected index changed Dropdown List - ddlLang - English, Italian, French, German
If English is selected from ddlLang Create new asp:Label, asp:textbox and asp:button. If French is selected create another new asp:Label, asp:textbox and asp:button. In the same way so on.... and when button submit clicked get all dynamic text box values and label values to Save to DB.
AutoGenerateColumns: Flase/True ( i tried both) If i remove the gvOff.Columns[index].HeaderText portions, GridView works fine, but when i put the gvOff.Columns[0].HeaderText, i get the exceptional error.
, i couldn't solve it. If you need further info, inform me.
EDITED:
Hold on! I commented the HeaderText portion and tested int i = gvOffer.Columns.Count; I found count is 0 eventhough the columns print out with DataBind()... Why? NOTE: AutoColumn in this case is set to true. I guess i will have to edit the column names from DataTable.
I Have the gridview control with 2 dropdown list and 2 text boxes,When the textbox chnaged event happen 1 row will create and the dropdown back to initial values( its not retaining the selected values),I am binding the control after text changed method,Is there any properties needs to be set or any other way we can retain the values in postbacks?