Change the Grid View Pages on button click in C# Asp.net - c#

I have a problem that I want to change the Grid View page on button click. Means Grid View paging concept on button click in C#. I have to click on a button having a particular number text, then this will shows the particular page of gridview corresponding to the Button clicked.
Thanks in advance.

You can use the PageIndex property for that.

Related

ASP.NET - Can't save changes on GridView because of button Postback

I have a GridView, and buttons that do actions (Edit, Save, etc). The GridView is created dynamically. Once I press Edit button, I add textbox (controls) on every cell of the GridView, with their respective text value, so it can be edited.
The problem comes when I click Save button, because when the method starts, it seems like there isn't any textbox in the gridview... so that makes me think if it's because some autopostback stuff when the Save button it's clicked.
Any thoughts about solving that?
EDIT: Clarifying what I want:
1) I got a gridview with data,
2) I put the data of each cell from each row into textboxes,
3) I put those textboxes in the gridview,
4) I do change data in those textboxes,
5) I can't save that data because when I click the Save button, the data on the textboxes deletes itself
You can't avoid postbacks, ASP.NET works with them.
When you click the save button, the page does postback and the Load event fires. In that event, you have to rebuild the page as before you clicked Save (put the textboxes).
If you don't do it, the textboxes aren't there no more and no text can be saved.
Edit: gives unique names to your textboxes, it seems non-sense, but ASP.NET need to hooks on names

Get the Rad button that were clicked after Post Back

I'm using telerik Grid which has a command button that adds new row/record or another command button that edits selected row/record.
Each grid is inside a twitter bootstrap tab content (Yes, I didn't use telerik tab). What is happening is that when one of buttons that I mentioned above clicked, I expect the tab that contains that button be active at page load.
So is there anyway to get that button so I can use it to activate the proper tab? (ID of that button is enough for me, I will do the rest with jQuery)
Every control that posts back, in an ASP.NET web forms world, sets the __EVENTTARGET and __EVENTARGUMENT (if there is an argument) form values. The __EVENTTARGET form variable has the client ID of the button, so that might be the optimal way. If it's within the grid, I'm not sure, but the __EVENTTARGET may either be the button or grid ID.

Reset a view in an asp.net MultiView

I'm using an asp.net MultiView control with 2 Views inside.
First view has a "create" button to create new customer. Clicking the "create" button will display the 2nd View of the MultiView which allows to enter customer information.
Second view has a "return" button to return back to the 1st view.
The problem is: after creating the first customer, clicking the "create" button again will render the 2nd view with first customer's information already entered.
Is there a way to reset 2nd view to its default state whenever the "create" button is clicked?
Perhaps, clearing out the viewstate?
Currently I'm using a recursive method to clear out all the inputs (textbox, radiobutton, dropdownlist, etc.). I just want to know if there's a cleaner/better way.
Thanks
Easiest way to do it is to have the return button do a response.redirect to the same page. It won't be terribly inefficient and you won't wave to manually reset anything.
You could possibly use OnClientClick on btnReturn to simulate a click on a hidden <input type="reset"> button.

Button in the Header Template of Repeater

I have an ASP.NET repeater which contains grid view and a panel which contains save button.
the repeater displays grid and save button for each employee..
if there are 5 employees then 5 grids and 5 save button will be displayed.
Now i want to move the save button to Header.. in that case i'll have only one save button for all the grids..
if any grid is modified and i click the Save button, how can we know which grid is edited.
pls help.
If the grids don't post back, i'm not sure it's possible to know which grid was edited. You could add an hidden field to the page (asp:HiddenField) and modify the value using javascript and then check the hidden value when the save button is pressed. Also, why do you have a save button? The gridview has full support for CRUD (Create/Read/Update/Delete) operations.
i think you can use "for each" to loop throw all items in the repeater
and you can check if there is any change in the item then save it if not then leave it and move to the next item.

Radiobutton checked change event not firing in gridview

I have a gridview where i have a radio button. What i need is to on the selection of the radiobutton i have to find the datakey of the gridview. Also one more issue with that is , i can select more than one radio button, which should not happen.
You need to use a literal control to inject radio button markup.
This will handle grouping so only one radio button is selected.
You cannot do it with the standard radio control group.
See this for a complete example with working code:
http://www.asp.net/data-access/tutorials/adding-a-gridview-column-of-radio-buttons-vb

Categories