I showed data in gridview.There are lot of column,so used scroll bar to grid.For finding out perticular record,used auto generated select button.Suppose I select one record,it become different in colour.When I exporting data to excel,it shows that coloured column and select button also in excel .So I want to hide that select button and color of row of selected column.Even when I am taking diffrent record,that time also showes one row colored.I want liked this when I am selecting one item from dropdownlist,gridview should get disappered and on button clicked gridview should appered.Gridview has paging and column are auto-generated.
It seems that you are using GridView's RenderControl to export the data. This method writes the current html of GridView. If you want exported data to be formatted other than the GridView's current format then, I suggest that you to use HTML Table method to export the data.
Related
I am creating a table dynamically.
Now I add some data to the table from Database.
On Every Row of the table I create a button.
Up to this it works fine.
Now when user clicks on that button I want to add a new row to the table just below the button was clicked. I mean I want to insert a new row between the existing rows.
Any Ideas?
If you are using a grid view or data table then apply the commandname property to the button then handle it in the grid view/data table command click method. From there you can determine which row the button is in and then create a new row and insert it below.
If you are creating the table HTML dynamically then it is a bit trickier, I would add HTML comments after each row with the row number and give each button a command argument with the row number too so I could replace the comment text with a new row.
tbl.rows.addAt(Position)
Here Positoion is the variable holding the value where to insert the new row.
when use this code you can insert row between other rows in datatable in vb.net
tbl.Rows.InsertAt(newRow, CurrentRow)
I have a DevExpress ASPx GridView control and am trying to implement sorting for the grid columns.
The gridView contains has integer values in one column, text in the rest. I also have a column which contains hyperlinks and is added through the code behind during run time.
I am using the Aspxgrid_CustomColumnSort event for sorting the grid.
I can achieve the sorting for the column which contains the integer values and texts successfully, however the same code is not working for the column with hyperlinks.
When I click on the column header the hyperlinks sorts in ascending order,
but when I click the header the second time the grid isnt getting sorted in the descending order, the hyperlinks are sorted in randomn order ( neither ascending nor descending)
And, further clicks on the header do not do anything.
Any advice/suggestion will be greatly appreciated.
Maybe this link will help: http://www.devexpress.com/Support/Center/p/B145444.aspx. In this page, someone had reported an issue using the GridViewDataHyperLinkColumn.
May I know how to show multiple records on the same row in Gridview?
the purpose of these enumerable data bound controls is to show one record/row/object per item template. If you want to show multiple records/rows/objects you will need an intermediate step to aggregate the individual record/row/object together.
then you could bind to the gridview. however, i would recommend the ListView so you can customize the layout however you like.
I have a relatively simple Listview that suddenly needs (due to new requirements) to have it's 'layout' extracted to a DataTable so that a common routine can convert it to an Excel spreadsheet for export purposes.
The ItemTemplate is just a series of Table Rows with some text, data-bound labels and textboxes with validators in the cells.
Usually, when trying to pull out a particular value (like what was entered into a text box), I use the ListViewItem's .FindControl method.
For Each objItem As ListViewItem In lvwOptions.Items
Dim objTextHrsLabor As TextBox = CType(objItem.FindControl("txtHrsOptByLabor"), TextBox)
decHours = CDec(objTextHrsLabor.Text)
Next
In this case, however, I'm trying to take all the data displayed - all the 'rows and columns' of the table that was created.
Inside the ForEach / Next loop of ListViewItems, I started a ForEach/Next loop of Controls for each instance's controls but I got some really strange results returned (like controls that had a couple of table cells in them).
I get the sense I'm headed in the wrong direction. All I want is for the nicely-formatted 5-line, 6 column table to be converted to a 5-line, 6-column data table.
Is there another avenue I should be looking at?
I would look at the underlying data source for your ListView.
The data source must be a collection or an IEnumerable and you should be able to iterate through it to build your data table.
If you know that all elements are of the same type then you can use the first element and look at its properties using reflection to determine which columns your table should contain. Then you can add DataRows to your table and fill in the columns using the property names.
This will probably be faster than iterating through the generated html of the ListView.
I used this approach for exporting a ListView to Excel: http://aspalliance.com/771_CodeSnip_Exporting_GridView_to_Excel.
I know it deals with a GridView, but I adapted it to a ListView (as long as the underlying structure is a table) and it worked fine for me.
HTH.
you can use..
listView1.Items[0].SubItems[0].Text
this will be helpful , really simple and easy . You can extract info right on the basis of index & use anyway you want.
How to display the datagrid in insert mode without any data in it.
The GridView is empty and contains only one header.
I want to insert the data in the GridView when the application is running.
What you could do is using an empty Binding Source to a List which would enable you to add new Rows.
Check out some samples of how to use the Binding Source here
Please have a look at these 2 examples:
Insert rows with a GridView
Adding Insert Capabilities to the GridView
I don't think the datagrid will be rendered if its data source is empty. To work around this problem you can give it a data source with only one item that is regarded as empty (for example a data table with one row where all columns have empty values). You can then check for this special case in your program logic.