Probably because you're messing with the listitem collection within the dropdown, you do that, it'll get confused because as far as it's concerned, it's a new datasource and therefore there's no selected. How are you marking which one is deleted in your codebehind?
I'd probably create a seperate object to hold the data, use that as datasource for your dropdown and rebind each time otherwise there'll be a greater chance for state issues.
Thank you! That's interesting. Could you please elaborate a little bit?
I rebind the datasource every time the page is loaded. Are you saying that this is considered as messing with the listitem collection?
The code I use to delete the item is very simple (obviously I am trying to mark the item but I cannot):
int iIndex = lstNames.SelectedIndex;
if (iIndex > -1)
Every time I change the selection, I would like to retrieve the selected index. I cannot because during postback it is set to 0. I have tried to save the view state, but that did not work either. My problem is that I cannot get the selected index at any time at all. If at any point I could retrieve its value, I can store it somewhere. The problem is that I am reading 0 at all times. I don't know what to do.
I lose the selectedIndex the moment I have some action that does a postback. I have tried to capture it in may places, during Page_Init, LoadViewState, SaveViewState, with the IsPostBack, and without it, etc. For the past two days, I have had no success.
...a little bit later...
I am starting to believe that it is a data binding issue. You were absolutely correct. When I remove the databinding code, everything works fine. I need to figure out why.
are you sure, you dont rebind the datasource at any place on postbacks? I mean, obviously your items
still appear in your listbox after postback, you would have mentioned it otherwise.
So your control gets these items either from viewstate or by rebinding the datasource. If you rebind it
on postback, the selectedindex is lost, but the items would still appear. I would suspect that in the first place,
but in your code, i can see the "if (!ispostback...)" part.
Hmm. Maybe you rebind it in some event?
Good luck, these things can really make one scream.
I want to upload multiple image files from within an InsertItemTemplate within
a FormView. That Formview is placed in an UpdatePanel. I searched the net for
2 days to find answers to my problem. I am aware that a full postback is required
to make the asp.net FileUpload control work and that a PostBackTrigger has to be set
inside the UpdatePanel. My problem is that the PostBackTrigger button that I place in
the Triggers section of the UpdatePanel can not be found since it is declared in the
InsertItemTemplate. Can this be solved some way. I have read that in this case it is
better to use an AJAX AsyncFileUpload control, but I can not find any examples where
multiple files can be uploaded. I doubt that this is the best way to solve my problem
since the upload starts immediately after a file on the local file system is selected.
I want to start the upload only when the Insert Button inside the InsertItemTemplate is
clicked and therefore do the handling in the ItemInserting event of the FormView.
Can anyone please point me to an example where this is done. I can not imagine I am the
only one having this problem.
Hi guys, I have a tiny misunderstanding in implementing my session timeout.
I have a asp.net solution with three pages, Default.aspx, Logout.aspx, and Home.aspx, ofcourse all these share the same web.config file.
In my web.config I have:
<!--this is my logout implementation-->
<forms loginUrl ="Default.aspx" timeout ="1" requireSSL="false" path="/" defaultUrl="Default.aspx"
<deny users="?" />
<allow users ="?"/>
but only the Default.aspx is timing out and refreshes. But I want that to happen in the Home.aspx, when no activity is received it must redirect to the Default.aspx.
I know I am messing up somewhere, can anybody help me please???
I have a grid view to which i am binding data from the employees table.
I am also displaying first name and last name in grid view. now i want the first name and last name under one main sub header name. Below is the example.
EmployeeId ContractNo ContactNo EmployeeName Summary
E001 Co123456 900878634 Xyz Abc PQR
I the above example i want First and Last below the EmployeeName as a subheader, means EmployeeName acts as a main header for First and last.
I also need to provide sorting on EmployeeName.
Can any one suggest me a solution by some code example or some useful link regarding this in order to provide subheader inside one main header in the same format.
I have a web page that uses the AJAX framework. Basically you choose something in a dropdown and click a button and the page is partially refreshed to show a gridview(which is inside an UpdatePanel with the trigger as the button). You choose a different option and click Go, the gridview is updated accordingly.
Now, I want to use sqlcachedependency in codebehind (since I'm not using SQLDatasource and doing it all programmatically). In my code, I have the code to populate the dropdown in Page_Load and in the Gridview_Load, I create my SQLCommand object. I found the following code and seems pretty simple:
SqlCacheDependency dependency = new SqlCacheDependency(comm);
int expire = 3;
DateTime exp = DateTime.Now.AddMinutes(expire);
But the question is, where do I put the code to ensure the DB isn't queried and data is actually retrieved from Cache??? Should I put it before or after my SQLDataAdapter.Fill in Gridview_Load? Or is it somewhere else?
Thanks in advance
Last Visit: 31-Dec-99 18:00 Last Update: 22-Oct-21 13:17