Getting Row from Gridview in Dev Express? - devexpress

How do I get a Row from a Gridview control in DevExpress?

I did some digging for you, and it seems like this is the best way to do it.

What are you trying to achieve?
Do you want to get instance of object displayed as grid row?
If so, try GridView.GetRow() method.

if you're not trying to do what przemaas has to say, then operate on the object that you're binding to (cause really, that's what the xtragrid is all about). If it's an xpcollection(T) that you're binding to, then any operations done on the records within it will propagate to the grid through the PropertyChanged event on the xpcollection.
If you're binding to a custom collection, then just inherit it from IBindingList and/or implement INotifyPropertyChanged.

Related

Is there any solution to controls repeated properties?

Is there any solution to controls repeated properties ?
An example would be that imagine you have 4 gridview but each of them have the same templates, same properties, same everything (except id of course). It happened to me several times to have more than one gridview that have the same properties.. so i will ask my question again... Is there any solution to controls repeated properties ? and how to apply your solution.
You could create a UserControl containing the control that you need to repeat and then the constructor for the UserControl to pass in the information that needs to be initialized.
It depends on what you want to do and how your controls are populated. If I understand very well, you have duplicate gridviews. If that is the case then you can create your gridview dynamically in the code behind and populate it there through a function as you can see here.
http://msdn.microsoft.com/en-us/magazine/cc163612.aspx
If not please provide more details and I would be able to help.

how to add items to Asp.Net ListView webcontrol

I have a ListView control in Asp.Net WebForms which display a set of elements, I have at the end a "More" button like Facebook for example. During the postback I want to get from database another 10 elements (I have already displayed 10 and I don't want to retrieve them again)
Something like this.
foreach (var item in New10Items)
ListView.Items.Add(index,DataItem)
the problem is with DataItem, how to Bind it before add it? what is the best way of solving this?
I don't want to store first 10 items on session or retrieve them from database again because is Really!!! bad for performance and memory, they are no so simple.
if you don't understand please ask, I really need a way to solve this as clean as possible.
Facebook though makes a REST service call and appends them using JavaScript. I'd recommend that if you could call a web service and append additional items to the HTML generated from the ListView, that would be a very efficient way. Otherwise, you're going to have to postback and rebind data or store it in session for the original data. That's how the control was designed to work.
HTH.

ASP.NET Gridview - What property exists to find out if the grid renders or not?

When there is no DataSource assigned to my grid it doesn't render which is great!
When the datasource is empty it doesn't render - also great :-)
I am implementing some custom navigation so i want to know if there is a property that tells me if the dataview is rendered?
If it is rendered i can show my custom bits otherwise i don't.
Problem an easy answer, but can't figure out which property it is
Anybody help?
Would checking to see how many rows it has be ok?
if (grid.Rows.Count > 0)...
You can also use EmptyDataTemplate to handle what happens when there are no rows.

Multiple controls with the same ID 'DXSelBtn0' were found. FindControl requires that controls have unique IDs

I got this error when i press a button, but i searched for that ID 'DXSelBtn0' i couldn't find it. Button is a Devexpress button, and i just add click event to it thats all. When i delete the event, i don't get that error. What should i do?
Thanks
Mehmet Şerif Tozlu
I would suggest that you create unbound columns instead as it is described in the topic available at:
http://documentation.devexpress.com/#AspNet/CustomDocument3732
If you are creating the button programatically, make sure you explicitly set the Id of the control to something unique. Or if you are in a loop, make sure you explicitly define a unique id for each control.
The DXSelBtn is a prefix used to generate IDs for select checkBoxes in the command column of the ASPxGridView. I tend to think that you are manipulating the grid in some way. Sorry, it is impossible to tell what causes this issue without your code.

Is custom paging of GridView (in ASP.NET, preferably 3.5) possible without using ObjectDataSource?

See title.
Using ObjectDataSource is associated in my mind with quick demos that you can see at conferences and in video tutorials (which typically tells me "don't do it this way in production").
Also I always like to have control over what's going on and when it happens. My other problem with ObjectDataSource is that is's declarative.
Looking forward for your help and opinions.
UPDATE:
I'm retrieving only one page of results from the database and the GridView.PageCount is read-only [sic!].
Yes, you need to define an PageIndexChanged event handler to perform the actual paging of data from your source before binding to the Data Grid, same idea for sorting but with a SortCommand handler.

Resources