I have a gridview in an updatepanel with sorting enabled and an event handler as follows:
protected void MyGridSort(object sender, GridViewSortEventArgs e) { var TheDirection = (e.SortDirection).ToString(); var TheColumn = (e.SortExpression).ToString();
I put a breakpoint just after these lines. Every time I press the column header, my variable TheDirection is always showing Ascending. Why is it not toggling from ascending to descending and back?
I was given help in a previous topic located here: Accessing Gridview In Another Form In this topic I had gridview rows that are selectable and a search window that returned search results. We found a way for me to select a row in the parent window of the search one. My issue now is that when the parent windows gridview is sorted, the function no longer selects the correct row. I was wondering if there was any way to access the gridviews sort expression and direction, or some other way I can do this so it accounts for sorting. Relavent code is as follow: This is in my parent window
<script type = "text/javascript"> function selectRow(index) { //Retrieve a reference to the table that represents the GridView var gridView = document.getElementById('<%=gvSideList.ClientID%>'); if(gridView) { //If able to get a reference to the table representing the GridView... var doPostbackArgument='Select$'+index; __doPostBack('<%=gvSideList.ClientID%>',doPostbackArgument); } }
This is in the child window
<script type = "text/javascript" > function selecttherow(index) { window.opener.selectRow(index); } </script> protected void gvresults_SelectedIndexChanged(object sender, EventArgs e) { //declare variables GridViewRow row; int index; int id; //retrieve index, row, and id from gvresults index = gvresults.SelectedIndex; row = gvresults.Rows[index]; id = Convert.ToInt32(row.Cells[5].Text); //fill a datatable from general with id's for selection SqlCommand cmd = new SqlCommand("SELECT ID FROM General", csbg); cmd.Parameters.AddWithValue("@id", id); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); //loop through the dt and find the index of the matching id from the search window for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["ID"].Equals(id)) { //execute script to select the matching row in the dataentry page string script = ""; script += "selecttherow("; script += i; script += ");"; ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "selecting", script, true); break; } } }
Let me know if you need me to further clarify anything.
I have already spent two day to solve this on my own but for some reason I can't. Maybe I'm missing the live cicle of the dropdownlist. I hve a three dropdownlist that filter a gridview and the other two dropdownlists One is "Year" the other is "Country" and the other "Species" Each one of them is filter by the other two. So if I filter for one year it will only show me the species and countries that have records on that year. So I have to reload the gridview and all the dropdownlist.
What happend is that since I'm filling again the dropdownlist with less values he can't remember the previous one. I have tried with the events: DataBinding, Load Unload and Init of the dropdown list to force it to remember. The conclusion I have reach is that the databinding and the load have the dropdown list of the previous page. So if I do
And the year was on the index 4 but after changing the country the year is now index 3 he mantains the index 4 showing me another year.............................
im having a login control in my website with a remember me option. i check the remember me but it does not remember me. here is a part of my web.config. i browsed over the other answers on this forum but nothing :( I also have the cookies allowed
I have a simple ASP page with databound grid (bound to an object source). The grid is within the page of a wizard and has a 'select' checkbox for each row.
And when the finish button is clicked, I iterate through the rows and check what's selected:
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e) { // Set the selected values, depending on the checkboxes on the grid. foreach (GridViewRow gr in GridViewMatches.Rows) { Int32 personID = Convert.ToInt32(gr.Cells[0].Text); CheckBox selected = (CheckBox) gr.Cells[1].FindControl("CheckBoxSelectedToSend");
But at this stage GridViewMatches.Rows.Count = 0! I don't re-bind the grid, I shouldn't need to, right? I expect the view-state to maintain the state. (Also, if I do rebind the grid, my selection checkboxes will be cleared)
NB: This page also dynamically adds user controls in OnInit method. I have heard that it might mess with the view state, but as far as I can tell, I am doing it correctly and the viewstate for those added controls seems to work (values are persisted between postbacks)
UPDATE: Could this be to do with the fact I am setting the datasource programatically? I wondered if the asp engine was databinding the grid during the page lifecycle to a datasource that was not yet defined. (In a test page, the GridView is 'automatically' databound'. I don't want the grid to re-bound I just want the values from the viewstate from the previous post!
Also, I have this in the asp header: ViewStateEncryptionMode="Never" - this was to resolve an occasional 'Invalid Viewstate Validation MAC' message
i have a dropdown list and what happens is that when i click on the dropdown button the list appears under other controls and it pops upwards. If it pops downwards and is non transparent then it would be visible .how is this achievable ?
I want to position my menu control on the right side of the page based on our design requirements.As a result, I want to make the arrow that indicates a submenu appear on the left of the menuitem as well as make all submenus flyout to the left now as well.
I have been struggling with this problem for a long time. Does anyone have any clue about this problem? I created a gridview and set the allowsorting to true. This gridview has four columns: Name, Position, StartDate, and EndDate. I want the gridview to be sorted on the EndDate.
Inside of the save event, I called the BindGrid() function to rebind the datasource to the gridview. The changes will shown immediately, but the problem is that the records are not sorting on EndDate. I have to refresh the page manually to get the view sorted.
the datatype in my database is Varchar, so that my gridview Sorting Function doesn't sort correct in sequence 1,2 3, 3 but 1,10,100, how can I sort in sequence 1,2,3,4 but no changing the datatype in database?
I populate a DataTable, then sort the DefaultView of that DataTable. When I set the DataTable as the source for my report, the sort doesn't work. here is the code (GetData returns a valid DataTable):
Dim dt As DataTable = a.GetData(Parm1, Parm2, Parm3) If rbtSortByField1.Checked Then dt.DefaultView.Sort = "Field1 ASC" ElseIf rbtSortByField2.Checked Then dt.DefaultView.Sort = "Field2 ASC" ElseIf rbtSortByField3.Checked Then dt.DefaultView.Sort = "Field3 ASC" End If rpt.SetDataSource(dt.DefaultView.Table) 'This also doesn't work 'rpt.SetDataSource(dt)
I have a issue, when I checked the "remember me" check box when login, but login is doesnt worked. If i unchecked the "remember me", the login function just working fine. It's weird, because this only happen in my production server, it's working fine in my local mechine.
In login control of asp.net there is a remember me checkbox. What is the functionality of this checkbox? What it does basically? Is there any way to put space between checkbox and its associated label?
I saw Windows Live login control has an extra checkbox Remember my password? How can we achieve this feature in our custom login control? I have read many tutorials but I can not able to solve my queries.
This code worked until I published a recent set of changes to the web site. It's very strange behavior that I am having trouble debugging. Basically, I implemented some custom code to allow custom configuration of login timeouts from an app settings variable.
When debugging the application, if I click remember me or not, Login works perfectly. Once I post the updated code to the live server, login only works if I have the Remember Me option unchecked. If I check remember me, it does not log in, and it cycles the user back to the default web page. If I access the site from IE on the live server, remember me works correctly.
i have a login, and wanted to know how i could use the remember me function, (so each time the user visits the site, even though they are not logged in, it would auto log them in) but without using the actual remember me checkbox. Is there any extra code i need to write, and if so, what?
I'm looking for a way to sort the rows of a datatable without setting the DefaultView.Sort to a specific column. I have a datatable in session that users can add records to. I want them to be able to sort the data by clicking on a button. But new records added after that need to show up at the bottom of the list until the sort button is clicked again.
Just spent about 8 hours googling and looking through this forum for a solution on how to make sure that I can dynamically sort. Here is the situation.
I have 1 Gridview that displays 10 different scenarios based on what button is clicked.
I am also returning only top 10 records. I am doing all of the data binding pragmatically. So I have BoundFields, HyperLinkFields etc.
I also want to sort some records. When I change DataSource SQL statement the gridview somehow remembers what the last sort value was and it errors out saying that value "x" cannot be sorted because it does not exists.
Here I get an error that says that the data source does not support sorting? Doesnt it say gridview1.allowsorting = false;
I also tried gridview1.sort("", SortDirection.Ascending); This does nothin... except query my database one more time because i have a onSorting event that looks like this:
[Code]....
Here is an example of just one of those SLQ statements inside GetSQLQuery: