Top (conditional) radio button always selected - c#

I currently pass some values over to one of my ascx.cs files, and it displays certain radio buttons depending on the value that is sent over. The radio buttons are instantiated in the .ascx side of things:
<asp:RadioButton ID="length5yr" GroupName="SubLength" runat="server" Visible ="false"
/>
<asp:label runat="server" id="Label5yr" Visible="false" style="width: 300px">
</asp:label>
<asp:RadioButton ID="length3yr" GroupName="SubLength" runat="server" Visible ="false"
/>
<asp:label runat="server" id="Label3yr" Visible="false" style="width: 300px">
</asp:label>
<asp:RadioButton ID="length2yr" GroupName="SubLength" runat="server" Visible ="false"
/>
<asp:label runat="server" id="Labelyr2" Visible="false" style="width: 300px">
</asp:label>
<asp:RadioButton ID="length1yr" GroupName="SubLength" runat="server" Visible ="false"
/>
<asp:label runat="server" id="Label1yr" Visible="false" style="width: 300px">
</asp:label>
<asp:RadioButton ID="lengthQuarterly" GroupName="SubLength" runat="server" Visible ="false"
/>
<asp:label runat="server" id="labelQuarterly" Visible="false" style="width: 300px">
</asp:label>
<asp:RadioButton ID="lengthMonthly" GroupName="SubLength" runat="server" Visible ="false"
/>
<asp:label runat="server" id="labelMonthly" Visible="false" style="width: 300px">
</asp:label>
I want whichever radio button that ends up being the first/top one displayed to be checked. I've been able to get the last radio button checked (which also gives me other problems anyways) - but how can I get that top one checked!?
This is the code for how I determine which radio button is displayed - I have only shown one of the options just to make the code a little bit easier to read.
foreach (Dictionary<string, string> d in orderOptions)
{
if (d["length"] == "one")
{
length1yr.Visible = true;
price1yr = d["price"];
rate1yr = d["rate"];
issues1yr = d["issues"];
premium1yr = d["premium"];
Label1yr.Text = d["description"] + "<br><br>";
Label1yr.Visible = true;
SubLength1yr = "1 year";
}

For a server-side solution, the easiest would be to iterate over the list of RadioButton and use some simple LINQ to select the first visible button.
Something like:
var buttons = new []{length5yr, ...};
var firstVisibleButton = buttons.Where(b=>b.Visible).First();
firstVisibleButton.Checked = true;
The above is probably more pseudo-code than anything, but without a full code sample, that's all I can do. I am sure you can figure out the details. The above code would have to execute after you have hidden/shown the RadioButton.
I should probably specify that the list you create (buttons) must follow the order in which the buttons are displayed for this to work properly.

Related

Capture Value From Hidden ItemTemplate Field

I have a gridview and I need to capture the value of my label, but have it not be displayed. ANytime I set it to hidden I am no longer able to capture the value. What should I alter so the label is hidden, but I still am able to capture the value? eghead is what I am wanting to hide but still capture the value of
<td valign="top" style="text-align: left; width: 200px;">
<asp:GridView runat="server" ID="gridview1" AutoGenerateColumns="false" GridLines="Both" ShowFooter="true" >
<Columns>
<asp:BoundField DataField="rdf" HeaderText="redfern" />
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat="server" Text='<%#Eval("egh") %>' ID="eghead" ></asp:Label>
<asp:CheckBox ID="Sans" runat="server" AutoPostBack="false" Checked='<%# Convert.ToBoolean(Eval("Remember")) %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
use the
style="display:none"
in the control. This way it will not be displayed in the UI but it will be available in the client side for manipulation.
Another alternative is to set a property of your checkbox and then use it using jquery or using javascript method. The asp.net renders the custom property as it is on client side.

ASP.NET, Multiple Val Summary not working; required field val not firing

I have a repeater with editable rows on the aspx page. The row has a textbox and a required field validator associated to it. On 'save' button click on that row, the required field valiator fires, It is tied to a validationsummary at the top of the page.
Now I have this panel below the repeater with a text box and a save button. This panel is 'opened' using the jquery show method on the click on a linkbutton at the top of this panel.
The required field validator is not firing for this texbox. I have a different validation summary for this textbox; as I need to trigger the validations on click on its save button only.
So I have the code like this,
<asp:ValidationSummary ID="validationSummary" ValidationGroup="ValidationGroup1" EnableClientScript="true" runat="server" />
<asp:ValidationSummary ID="validationSummary1" ValidationGroup="ValidationGroup2" EnableClientScript="true" runat="server" />
<asp:Repeater ID="Teams" runat="server" OnItemCommand="ItemCommand" OnItemDataBound="ItemDataBound">
<HeaderTemplate>
<table >
<tr>
<th>
<asp:Label ID="lbTeamNameHeader" runat="server" Text="TeamNameHeader"></asp:Label></th>
<th></th> </tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:TextBox ID="txtTeamName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txtTeamName")%>' />
<asp:RequiredFieldValidator ID="reqdFieldValTeamName" ErrorMessage="Field cannot be blank" ValidationGroup="ValidationGroup1" runat="server" Display="None" ControlToValidate="txtTeamName"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regularExprTeamName" ErrorMessage="Invalid input for the team name" ValidationGroup="ValidationGroup1" Display="None" ControlToValidate="txtTeamName" runat="server" ValidationExpression="^[a-zA-Z0-9]+$"></asp:RegularExpressionValidator>
</td>
<td>
<asp:Panel ID="panelSave" runat="server" Visible="false">
<asp:LinkButton ID="linkbuttonSave" runat="server" CommandName="Save" ValidationGroup="ValidationGroup1" Text="SAVE" />
<asp:LinkButton ID="linkbuttonCancel" runat="server" CommandName="Cancel" Text="CANCEL" />
</asp:Panel>
</td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
<asp:LinkButton ID="linkbuttonAddTeam" runat="server" Text="Add New Team" />
<div id="AddPanelDiv" style="display:none;">
<asp:TextBox ID="txtAddTeam" runat="server" />
<asp:RequiredFieldValidator ID="reqdFieldValAddTeam" ErrorMessage="Field cannot be blank" ValidationGroup="ValidationGroup2" runat="server" Display="None" ControlToValidate="txtAddTeam"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regularExprValAddTeam" ErrorMessage="Invalid format" ValidationGroup="ValidationGroup2" Display="None" ControlToValidate="txtAddTeam" runat="server" ValidationExpression="^[a-zA-Z0-9]+$"></asp:RegularExpressionValidator>
<asp:LinkButton ID="linkbuttonCancel" runat="server" Text="CANCEL"></asp:LinkButton>
<asp:LinkButton ID="linkbuttonSaveNewTeam" runat="server" OnClick="linkbuttonSaveNewTeam_OnClick" Text="SAVE" CausesValidation="true" />
</div>
Why on earth the validators for the bottom panel fire? On click of that save button, it straightaway goes to the page method onclick.
If I remove the validation group and click on the save in the repeater, it fires! But thats not what I want..
You are missing ValidationGroup="ValidationGroup2" on your second button it looks like.
<asp:LinkButton ID="linkbuttonSaveNewTeam" runat="server" OnClick="linkbuttonSaveNewTeam_OnClick"
Text="SAVE" CausesValidation="true" ValidationGroup="ValidationGroup2" />

Firefox needs two clicks to set validators correct

I have a strange problem, but I can't get a solution:
We use the Infragistics WebDataGrid, in which I set a dropdown and a textbox.
For both of them I set a requiredfieldvalidator:
<asp:RequiredFieldValidator ValidationGroup="attrib" runat="server" ControlToValidate="ddlIndRoleAttribType" ToolTip="Attribute Type is not set." InitialValue="-- not selected --" Text="!" Display="Dynamic" />
</div>
</ItemTemplate>
</ig:TemplateDataField>
<ig:TemplateDataField Header-Text="Value" Key="IndRoleAttribVal" Width="50%">
<ItemTemplate>
<div>
<stgwc:TextEdit runat="server" Width="300px" ID="txtIndRoleAttribValue" />
<asp:RequiredFieldValidator ValidationGroup="attrib" runat="server" ControlToValidate="txtIndRoleAttribValue" Width="90%" ToolTip="Attribute Value is not set." Text="!" Display="Dynamic" />
</div>
</ItemTemplate>
</ig:TemplateDataField>
<ig:TemplateDataField Header-Text="Action" Key="IndRoleAttribAction" Width="40px">
<HeaderTemplate>
<stgwc:ImageLinkButton runat="server" ID="btnCreateNewAttribute" CausesValidation="false" ImageUrl="~/Images/base/Icons/16x16/add2.png"
ToolTip="Add new Attribute" CommandName="Create" />
<stgwc:ImageLinkButton runat="server" ID="btnSaveAllAttributes" ValidationGroup="attrib" ImageUrl="~/Images/base/Icons/16x16/disk_green.png"
ToolTip="Save all Attributes" CommandName="Save" />
<stgwc:ImageLinkButton runat="server" ID="btnCancelChanges" CausesValidation="false" ImageUrl="~/Images/base/Icons/16x16/undo.png"
CommandName="Cancel" ToolTip="Discard changes" />
</HeaderTemplate>
<ItemTemplate>
<stgwc:ImageLinkButton runat="server" ID="btnDeleteAttribute" CausesValidation="false" ImageUrl="~/Images/base/Icons/16x16/delete2.png"
ToolTip="Delete this Attribute" CommandName="Delete" CommandArgument='<%# Bind("IR_ATTR_ID") %>' />
</ItemTemplate>
</ig:TemplateDataField>
</Columns>
</stgwc:WebDataGrid>
I do a postback if a new item should be created, then I set it to the datasource and reload it, something like this:
dgrIndRoleAttributes.ClearDataSource();
dgrIndRoleAttributes.Rows.Clear();
dgrIndRoleAttributes.DataSource = null;
dgrIndRoleAttributes.DataSource =
(Session[Constants.Session.RoleAttributes.ToString()] as List<TmpIndRoleAttribute>);
dgrIndRoleAttributes.DataBind();
Now comes the funny part: When I press enter after adding a new row, Firefox (only Firefox, on IE it works proper), seems to think the validators on the validator-group attrib arent set proper and I need to click twice, to make it save.
If I check this with the firebug, I see both validators being on display: none, so this cant be problem. As said, this happens only on Firefox, and I cant reproduce it on a small testsample.
Has anyone a idea, what could cause this behavior? Since I'm not used to this validators, I can't imagine, what could cause this problems.
Thanks for you response!
Matthias
Edith says: It's a infragistics bug... Another one... I use in this case the normal asp textbox and change the style with some css.

Listview sort code apparently interfering with item processing code

Running VWD 2010 Express on a windows 7 machine.
I have a asp:listview (on a tab) that has column headers that sort the data (with no code on my part). This part works when it is by itself. But it fails when I try to then put in code to support the items in the list. So here is what I have so far:
(1) I can sort the items in a listview by clicking on a header ("title" in this case)
asp:ListView provides a mechanism for sorting the list by clicking on the title without using code behind. We can do this with a button like so:
<asp:Button runat="server" ID="SortTitle" Text="Title" CommandName="Sort" CommandArgument="sTitle" />
No code behind. This title is in the header which is outside the item template. It works fine. I can sort lists ascending and descending to my heart's content by clicking on the associated header. This is good, but I also would like to have the program "do something" when an item in the list is clicked.
(2) I can make something happen when I click on an item in the list.
Fortunately, there is a mechanism for controlling what happens when an item is clicked in the list via the OnItemCommand attribute in the asp:ListView tag.
<asp:ListView runat="server" ID="lvWebsites" DataSourceID="websiteSuggestionsDataSource" OnItemCommand="lv_website_click" >
This works kinda so-so. It does what I want, but it reloads the page (which I don't want to do). It's a separate issue and I may open a different question on that. The main thing is that I can click on the item in the list and it executes some code behind.
The real problem comes in when I use (1) and (2) together. When I do that, it ignores the CommandName="Sort" in the button tag and executes the code behind (lv_website_click) regardless of whether I click on the header (title) or an actual item in the list. It's as if the system makes no distinction between a header in a listview and an actual list item in the listview.
Here's a subset of the actual code I'm using. I'm using tabs and this particular listview is on the first tab so I include that...the entire code is a fair bit longer, but I think you can get the general context with this (and most of the rest is repeats of this code).
<div id='tab-container'>
<div class="tab-content" style="width:1000px">
<h1 class="tab" title="Feedback on the site">Site Feedback</h1>
<asp:ListView runat="server" ID="anID"
DataSourceID="mydatasource"
OnItemCommand="lv_website_click" >
<LayoutTemplate>
<table id="table1" style="background-color:White;border-collapse:collapse;" width="100%">
<tr style="background-color:White">
<td width="75%">
<asp:Button runat="server" ID="SortTitle"
Text="Title" CommandName="Sort" CommandArgument="sTitle" /></td>
<td> <asp:Button runat="server" ID="LinkButton1"
Text="Posted" CommandName="Sort" CommandArgument="sDate" /></td>
<td> <asp:Button runat="server" ID="SortDate"
Text="Status" CommandName="Sort" CommandArgument="sStatus" /></td>
</tr>
<tr runat="server" id="itemPlaceholder">
</tr>
</table>
<asp:DataPager runat="server" ID="datapagerSites" PageSize="10" style="background-color:White" enableviewstate="false"
PagedControlID="lvWebsites" >
<Fields>
<asp:TemplatePagerField>
<PagerTemplate>
<b>
Page
<asp:Label runat="server" ID="CurrentPageLabel"
Text="<%# Container.TotalRowCount>0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0 %>" />
of
<asp:Label runat="server" ID="TotalPagesLabel"
Text="<%# Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize) %>" />
(
<asp:Label runat="server" ID="TotalItemsLabel"
Text="<%# Container.TotalRowCount%>" />
records)
<br />
</b>
</PagerTemplate>
</asp:TemplatePagerField>
<asp:NextPreviousPagerField
ButtonType="Button"
ShowFirstPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false" />
<asp:NumericPagerField
PreviousPageText="< Prev 10"
NextPageText="Next 10 >"
ButtonCount="10" />
<asp:NextPreviousPagerField
ButtonType="Button"
ShowLastPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false" />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr1" runat="server" style="background-color:#ECE5B6;" >
<td><asp:Button BackColor="#ECE5B6" CommandName="lcommand" runat="server" ID="Title" Text='<%# Eval("sTitle")%>' CommandArgument='<%# Eval("sID") %>' /></td>
<td><asp:Label runat="server" ID="Label1" Text='<%# Eval("posted")%>' /></td>
<td><asp:Label runat="server" ID="Status" Text='<%# Eval("sStatus")%>' /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr id="Tr1" runat="server" style="background-color:#FAF8CC;" >
<td><asp:Button BackColor="#FAF8CC" CommandName="lcommand" runat="server" ID="Title" Text='<%# Eval("sTitle")%>' CommandArgument='<%# Eval("sID") %>' /></td>
<td><asp:Label runat="server" ID="Label1" Text='<%# Eval("posted")%>' /></td>
<td><asp:Label runat="server" ID="Status" Text='<%# Eval("sStatus")%>' /></td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
</div>
</div>
It strikes me I could maybe do both things in my own code to handle the items, but I really don't like that as I would like to use the automatic sorting behavior I get from the Listview control.
I would think OnItemCommand="lv_website_click" in asp:listview tag would apply to the items and the CommandName="Sort" CommandArgument="sTitle" would apply to the headers (used for sorting) because they are outside the itemtemplate. Apparently that is not true.
IS there a way to use both of these (sorting with a click on header AND code behind for items in the list) so they do not conflict with each other?
The solution is in the code-behind.
protected void lv_website_click(object sender, ListViewCommandEventArgs e)
{
if (!e.CommandName.Equals("Sort")) {
int searchID = Convert.ToInt32(e.CommandArgument.ToString());
TableAdapters.SuggestionsTableAdapter sAdapt =
new TableAdapters.SuggestionsTableAdapter();
SuggestionsDataTable tbl = sAdapt.GetDataByID(searchID);
tbMessage.Text = tbl.Rows[0]["message"].ToString();
lbField2.Text = tbl.Rows[0]["field2"].ToString();
lbStuff.Text = tbl.Rows[0]["stuff"].ToString();
}
}
The key is the "if" surrounding the body of the method. If it's not a sort event (i.e. the CommandName is not equal to "Sort" then do whatever it is you're supposed to do when you click on an item. OTHERWISE, if it is a sort, just ignore the code. I misunderstood what was happening here. I thought it was ignoring the sort and executing the other code regardless. What was happening is that if the CommandName is Sort, then it is doing the sort, but it is also executing my behind code (which is where it was having the error).
That is, it was not a problem with the aspx (as I had thought), but with the c# behind.

Getting Failed to load viewstate error

First off, I am not dynamically creating any controls. This is the order I take to produce the error:
I have a listview on the page, when I click the edit link under the listview, I display a panel which is hidden by default. The panel has a few buttons on it along with some listboxes. When I click an item in the listbox or click one of the buttons, I get the following error:
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
Again, I am not creating anything dynamically, I am just hiding the panel with the controls by default and then displaying them, so I am not sure why I am getting this error.
Here is some code:
PAGE LOAD
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Session["Albums"] = null;
Albums = AlbumCollection.GetAlbums(Common.GetUserName(),
ddlAlbumType.SelectedIndex);
lvwAlbums.DataSource = Albums;
lvwAlbums.DataBind();
}
}
When I click the edit link, this is the code that runs:
protected void lvwAlbums_RowEditing(object sender, ListViewEditEventArgs e)
{
this.AlbumId = int.Parse(
this.lvwAlbums.DataKeys[e.NewEditIndex].Values["AlbumId"].ToString());
this.AlbumName=
this.lvwAlbums.DataKeys[e.NewEditIndex].Values["AlbumName"].ToString();
Album album = new Album(this.AlbumId);
ViewState["AlbumId"] = this.AlbumId;
ViewState["AlbumName"] = this.AlbumName;
pnlAlbum.Visible = true; // This panel holds the controls
btnEditAlbum.Visible = true;
btnCancel.Visible = true;
EditAlbum(this.AlbumId);
this.lvwAlbums.EditIndex = e.NewEditIndex;
AlbumCollection.GetAlbums(Common.GetUserName(),ddlAlbumType.SelectedIndex);
}
If I click the cancel button, I get the error, but it also happens if click another button on the panel such as Add/Remove... Here is the code for the Cancel button:
pnlAlbum.Visible = false;
this.lvwAlbums.EditIndex = -1;
AlbumCollection.GetAlbums(Common.GetUserName(), ddlAlbumType.SelectedIndex);
Here is the aspx/html for the ListView:
<asp:ListView ID="lvwAlbums"
runat="server"
GroupItemCount="5"
DataKeyNames="AlbumId,AlbumName"
OnItemEditing="lvwAlbums_RowEditing"
OnItemCommand="lvwAlbums_ItemCommand"
OnItemDeleting="lvwAlbums_RowDeleting"
OnSelectedIndexChanging="lvwAlbums_SelectedIndexChanging"
OnPagePropertiesChanging="lvwAlbums_PagePropertiesChanging">
<EditItemTemplate>
<td>
<div>
<asp:TextBox ID="txtAlbumName" runat="server"
Text='<%# Eval("AlbumName").ToString().Trim() %>' />
<asp:LinkButton ID="lnkView" runat="server" Text="View" CommandName="View"
CommandArgument='<%# Eval("AlbumId") %>'>
</asp:LinkButton>
|
<asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandName="Edit"
CommandArgument='<%# Eval("AlbumId") %>'>
</asp:LinkButton>
|
<asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" CommandName="Delete"
CommandArgument='<%# Eval("AlbumId") %>'>
</asp:LinkButton>
<br />
<span>Songs:
<%# Eval("total") %></span>
</div>
</td>
</EditItemTemplate>
<LayoutTemplate>
<asp:DataPager runat="server" ID="ItemDataPager" PageSize="20"
PagedControlID="lvwAlbums">
<Fields>
<asp:NumericPagerField ButtonType="Link" NumericButtonCssClass="pager" />
</Fields>
</asp:DataPager>
<table>
<tr>
<td>
<table>
<asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<asp:Literal ID="litAlbumName" runat="server"
Text='<%# Eval("AlbumName").ToString().Trim() %>' />
<br />
<asp:LinkButton ID="lnkView" runat="server" Text="View" CommandName="View"
CommandArgument='<%# Eval("AlbumId") %>'>
</asp:LinkButton>
|
<asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandName="Edit"
CommandArgument='<%# Eval("AlbumId") %>'>
</asp:LinkButton>
|
<asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" CommandName="Delete"
CommandArgument='<%# Eval("AlbumId") %>'>
</asp:LinkButton>
<br />
<span>Songs:
<%# Eval("total") %></span>
</td>
</ItemTemplate>
</asp:ListView>
Here is the markup for the Panel:
<asp:Panel ID="pnlAlbum" runat="server" Visible="false">
<asp:ListBox ID="lstAvailableSongs" runat="server" SelectionMode="Multiple">
</asp:ListBox>
<asp:Button ID="btnAddAll" runat="server" Text="Add All" OnClick="btnAddAll_Click" />
<asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" />
<asp:Button ID="btnRemove" runat="server" Text="Remove" OnClick="btnRemove_Click" />
<asp:Button ID="btnRemoveAll" runat="server"
Text="Remove All"OnClick="btnRemoveAll_Click" />
<asp:ListBox ID="lstSelectedSongs" runat="server" SelectionMode="Multiple">
</asp:ListBox>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
<asp:Button ID="btnEditAlbum" runat="server"Text="Save"
ValidationGroup="CreateAlbum" OnClick="btnEditAlbum_Click" />
<asp:Button ID="btnSaveAs" runat="server" Text="Save As" ValidationGroup="CreateAlbum"
OnClick="btnSaveAs_Click" />
</asp:Panel>
Here is some extra info:
I put an update panel around one of the listboxes in the panel and when I clicked the edit link under a listview item, I received the following error:
Microsoft JScript runtime error: Sys.InvalidOperationException: Could not find UpdatePanel with ID 'ctl00_ctl00_InnerContent_MainContent_UpdatePanel4'. If it is being updated dynamically then it must be inside another UpdatePanel.
Putting an UpdatePanel around the whole asp.net panel resolved the issue above, but I still get the Failed to load viewstate error when clicking on Cancel or Add, etc...
First off, you probably need to rebind the ListView after setting the EditIndex. (honestly, I haven't used ListView at all, but this is how the other repeater controls work) What does "EditAlbum()" do?
Your code is a little odd... why do you have the same controls in your EditItemTemplate as in the ItemTemplate? Ie, the Edit button should only be in the ItemTemplate... Then EditItemTemplate should have a Save or Cancel button.
Bottom line... your control tree is different on LoadViewState than it is when SaveViewState was called. One thing you can do is override these methods and then put a breakpoint there to manually look at the Controls collection in the debugger. You will probably see that the controls inside the ListView are different. But try my first suggestion before you do this.
Question for you:
in your Page_Load you have
Albums = AlbumCollection.GetAlbums(Common.GetUserName(), ddlAlbumType.SelectedIndex);
but in lvwAlbums_RowEditing(..) and in btnCancel_Click(...) you have
AlbumCollection.GetAlbums(Common.GetUserName(), ddlAlbumType.SelectedIndex);
shouldn't these be (Albums = ...)
Albums = AlbumCollection.GetAlbums(Common.GetUserName(), ddlAlbumType.SelectedIndex);

Categories

Resources