Gridview is not set at first page during binding - asp.net

I have dropdown list on my page. When I click on submit button, gridview is filled based on the choice in the dropdown list. It also contains pagging. Now when I move on page two and then change dropdown list value and again fill the grid, it fill perfectly but shows from the previous page index and not from the first page. I trid using "Gridveiw.PageIndex=0" but still its not working. What might be the reason behind this??

first set Gridveiw.PageIndex = 0; like you are doing and then bind the grid.

Related

Looking for a vb.net code to add existing buttons/text boxes/drop down lists, etc. to a container, or holder?

I'm using vb.net. Basically, I have a drop down list, text box and a submit button. You choose a movie director from a drop down list, then type in a movie, click button and it adds the data to my database.
There's another button which hides/shows drop down list, text box and submit button using Visible = True and Visible = False, but what I don't like about it is when it hides the things I said before, it leaves some white/empty space like if they are still there, but not visible.
Is there anyway to put some kind of holder/container and place a button which when clicked could add my drop down list, text box and submit buttons to that place?
Cheers,
E.N.
I assume that you are working with WinForms in Visual Studio. In the Toolbox the controls which could help you out of this situation are in the "Containers" section. Among others, there is a Panel, a FlowLayoutPanel and a TableLayoutPanel (see this video on msdn for a TableLayoutPanel Demo). They can help you to organize controls. Especially the FlowLayoutPanel places the controls automatically. But you can always change the Top and the Left properties of any control, to move them around to the desired place or group some of them on a Panel and change the Location of this one one.
You can add a control to a container by using the Add method of its Controls property. However, if the control is already on the form (since you are asking how to add an existing control) you must remove it from the form before.
Me.Controls.Remove(myButton)
panel1.Controls.Add(myButton)

How can I add rows of data with dynamic images in Flex?

I want to add specific images to a datagrid row, depending on the data displayed on that row. These images need to be functional buttons with click handlers and everything.
For example, if a row displays status of a certain element, like "Editable" then the image displayed in the cell next to it needs to be a green flag, if it isn't Editable then I red flag should appear.
If you just need images and click handlers, there is an option to embed icons inside a datagrid.
Also, for a datagrid ,clicking on any row triggers the click event,the handler to which will give you datagrid.selectedIndex as the index of the row you clicked, which you can then use to get the data in that specific row and according to the data do a specific action you need.
To render icons in datagrid, you might want to check for labelFunction attribute, which allows you to specify a function , each time data in a datagrid row is filled, which yuo can use to determine the icon you would need the datagrid to render and show to the user.

Edit ASP.NET GridView Cell on mouse over

in my Project there is Asp.net GridView ( that putted into a update panel).
i did open Gridview In Jquery Ui Dialog.
Is there any way exist to edit a specific column grid View cells in microwave on mouse over on that cell?
for example displaying a div on that position and doing an action.
please give me help.
thanks
You could use hover jQuery function:
$(selector).hover( handlerIn(eventObject), handlerOut(eventObject) )
it takes 2 parameters:
1). Function which called on mouse goes in element
2). Function which called on mouse goes out element
In the first parameter you could show div, and hide it in the second one.

Adding a new row in between rows in a grid view

I have an ASP .net grid view. It has some template columns like a command button, a text box, and a dropdown control. When I click the command button, a new row needs to be inserted below the current row (from where I hit the command button).
If I have rows 1 and 2 and I hit the command button in row1 a new row needs to be inserted between rows 1 and 2
Now in the new row I should be able to select values from dropdown and enter some value in a text box and finally hit my save button. (Which should work fine as I am expecting)
The grid view is bound to some data source say for instance a datatable for now.
Oneway that I could think about is when Command button is clicked, I can add a new row to the datatable in my server side code and rebind the grid. But I am not sure that, from a UI perspective how I can make sure that the new row goes exactly below the row from where I hit the command button.
Any thoughts or comments?
I think a much easier approach will be if you try to add the row in your data source and then bind to the GridView again. This is easy if you have DataSet or a custom entity collection. Since, you are using DataTable this will also work. Handle the click event and find the row that the user clicked. Go back to the dataTable and add an empty row there. This will make sure that the controls inside the GridView are persisted and you don't have to worry about adding DropDown controls etc.
You have to sort the datasource by an virtual index saved in an invisible column. On first databound(perhaps you take a DataView because of ots sorting capability) it will set to the original rowindex. After first hit of the save button you get the datatable again from database and add the additional row with an index after the "selected" row. Then you bind the GridView again with the sorted DataView.
I think you need another invisible column to detect the "temporary" row. If you dont need to edit the "normal" rows then you can use edititemtemplate for this. Otherwise you can make the dropdown and textbox visible and the other controls invisible in GridView.OnRoawDataBound.
There is a code sample that is used for adding a new row in between rows in a grid view.

webusercontrol problem

I have one webusercontrol for Datepicker. When I am using this control in content pages it works fine. I have many controls in content page (textbox, label, etc.). All controls are inside a table. I have placed usercontrol inside <td>. When I click on an image, the calendar control is showing. But that time this calender control pushes all other controls (textbox, label, etc.). I have set the z-index at a higher value, but still it's not working.
alt text http://www.shareimages.com/images/thumbs/0/0/1/39586-qJyWopyZlqGlk6CVmw-datepicker.jpg
Z-index will not work for you becuase it is made for absolute,fixed and relative positioned elements.
in your case what happened is when the calendar was not loaded the cell was empty but when you opened the calenday it filled the cell and expanded the row which it expanded the table. which causes the elements who are inside the tabe to change their position.
try not to put the calendar over the other rows. create new column. set rowspan and put the calendar inside that cell which it will expand in its cell with out affecting the other rows since it is in different column (this will change the desiegn but it is the easy way)

Resources