DataRepeater becomes empty - asp.net

I'm using a DataRepeater control in my VB.Net application so I can make a custom-made list control.
I know it's main functionality is to work with dataSets and stuff, but I don't actually want to transfer my stuff into a database because in the program's context it doesn't actually make any sense.
So my goal here is to use a dataRepeater to list the contents of a mail inbox.
Everything works just fine until I scroll down the control. As I scroll down/up to see every item (in this case, every listed e-mail), the contents disappear and all I can see is a bunch of lines with the controls' default values assigned - like "Label1" and so on.
This is how I'm filling the dataRepeater (abreviated):
For each m as Message in mail.Inbox
dr.Addnew()
With dr.CurrentItem
.Controls("lblFrom") = m.From
.Controls("lblSubject") = m.Subject
End With
Next
As I said, the dataRepeater shows up perfect until I scroll it up/down, and when I do it all the data just disappears remaining only the items with the controls' default (design-time) values.
Am I missing something here? Or is it just not possible to work with a dataRepeater to fulfil my idea?
UPDATE:
Got my answer right here!

The repeater isn't going to hold the values on its own. You dont have to use a datasource, but you have to use something. Here is an example where they used a simple integer array: VB.NET Repeater Simple Data Binding Without Datasource

Related

I need to display a pop up table on clicking a button in vb.net. How do i do this without the gridviews just on plain button click?

I need a table to pop up or flash on the users screen when a button is clicked
It is a reference table, users can go back and check the codes while filling a form. This is to be done vb.net. Please help me i need the simplest solution possible
in my opinion:
1) If you don't insist on formatting and you would like to only display table data, you can simply write the data into string, which you will display in a MsgBox dialog. You'll probably will have to take care about partial string lenghts in columns (trim, or complete with spaces to a specific length) and then it will look OK. Bellow is an example of such data (only a test dialog) without any trimming/completeng:
2) For a serious table, you'd have to either use datagrdiveiw (or such) in a separate form, or draw your table using GDI, which would be a rather complicated and eccentric method.

ASP.Net 4.0 image select and change source

If I have a set of image (buttons) or even just plane images, 5 in a row, and I want to achieve the following, what would be the easiest way, I can't realy find a good solutions to this:
On clicking either of the images, it needs to get a new src, but others need to be restored to the original state.
A Asp:Label needs to be set on clicking, based on the image clicked
On doing a PostBack, I need to know which one is selected
Asside from this, it's asp.net 4.0, so single quotes are giving me javascript pain.
On clicking either of the images, it needs to get a new src, but others need to be restored to the original state.
First of all you have to create a function in which you will set all 5 images to the original state.
Then be sure to give same class name to each image element.
After that crate a function which will fire according to class name like
$(".classname").click(function(){
//first call the function which will set all 5 images to original state.
//then change the source of the current image. onwhich user has clicked as below:
$(this).attr("src","new source");
// here you can store the id of current image in a variable to keep the record which images have been clicked
});
A Asp:Label needs to be set on clicking, based on the image clicked
you can easily set the Asp:Label in above function. If you are familiar with javascript code. Its too simple to set.
On doing a PostBack, I need to know which one is selected
After creating the first function your rest of two steps get completed them selves.
in above function you have saved the IDs of images on which a user has clicked in a variable.
on doing postback you can easily save the varibale's data in hiddenfield or assign it to static varibale or what ever the way you like.
at last you can access it in code behind.
If i have to do this thing. i'll follow the above process. Its far easy and fast process. Everything can be done at client side.
what you think?

ASP.net: Complex validation of dynamically created DropDownLists

I have a GridView with records of the database.
I create two DropDown lists dynamically for each selected item. That means, if I click select, two DropDown lists appear, the first one defines a start position, the second one a stop position. Both includes numbers (depending on how many items I have selected). If I have selected 5 items, all DropBox controls include the values 1 - 5. Everything is done by code behind.
Now I want to validate that. The stop Control shall be set to a higher one as the start control. Further more, each area that is already used, is not allowed for the next controls. E. g. if I select in the first pair of DropDown lists the area 1-5, I shall not be able to choose 2-6 with the next pair of controls.
How can I do that. I thought about javascript but that could be very tricky because everything is done with code behind. The validation controls are nice, but I don't know how to validate such a complex thing...
Any Ideas?
thank you for your answers!
I dont wont to do a async postback each time, especially because the lists shouldnt be limited during the changes. I solved it in that way:
The user clicks on save, I create a bool array for each dropdown item, then I loop through all dropdownlists in the placeholder. If there is a area from 3 - 5 I set the values with index 3-5 in my bool array to true. If one of these values is already true, there must be a wrong selection in the start/stop positions.
I think, its not a very nice way but works pretty fast and does everything I want. If someone has a better idea, please let me know... ;)
Thanks!
Stefan

ASP.NET Dynamic Menu

I have to create a Dynamic menu in ASP.NET. I want to use dynamic LinkButtons (or can be a Menu Control), but should be appended with sequence numbers. Eg: 1,2,3a 3b etc..and these sequcenes could be dynamic. Any idea. I used a repeater with a label and LinkButton in it, but having problems with view state. Any idea how to append sequence to menu??
Essentially, you have two paradigms with web applications, at least from this conversation's standpoint.
Stream out the HTML, creating it as you stream
Create containers that can bind to data and shape the data
Your concept seems to be "only #1 is dynamic", but that is not true. Any time you can change the data and get a different output, you are dealing with something dynamic. My personal feeling is shape the menu data prior to binding. This cannot always be done, but more oft than not, it can. The second method would be to attach to an event like a item binding or row binding event. Controlling the HTML stream and writing out individual items is generally my last resort.
Now to the viewstate issue. Viewstate is a bastard when you start adding things to an item after binding and semi-problematic when you are playing the dynamic game from #1 above. The problem is things added after the initial definition cannot easily be set up with automagic bits. You end up having to rebind each time. This is why shaping data and then binding is superior. Even in cases where you have to rebuild, you can cache the shaped data and quickly rebind. It takes more "up front" work, but is less problematic.
The actual container you are binding with is inconsequential. Unless you can't use the menu control for some reason (other than having to dynamically add, which can be solved by playing with the bound data), I would head this direction. Actually, I would head this direction and use the CSS friendly adapters so you can alter the look and feel more easily. :-)

AspxGridView: Unable to sort without SortCount at the beginning

I'm using ASPxGridView with its default sorting property.
Before, it was not viewing any record after I press to any column name for sorting. But(there's a view all button) after I click to "View all", it was coming in a sorted way.
So I've figured out that I had to Bind grid again if (ASPxGridView1.SortCount == 1).
Now it's working, but only at the beginning, when I click to any column name for sorting, it returns no record, then it works perfectly.
So I need to do something instead of SortCount when the grid loads for the first time.
What could it be?
I do not know your code, but I think that the solution to this issue is discussed in the
Why might paging (sorting, grouping, filtering) not work in the ASPxGridView?

Resources