How to prevent reposting of data before refresh? - asp.net

Suppose there is button on which there is event for adding the total sum(there is coloumn Amount in gridview) and posting the data in gridview i.e update of gridview. I want that when user click on button it will update the gridview i.e data will inserted in geridview but it will not add current numeric value to the total sum unless user refresh the page.
For this how to do? Please tell me.

You can use telerik's ASP.NET AJAX controls.
Visit here http://www.telerik.com/products/aspnet-ajax/grid.aspx

Related

How to create and edit gridview at runtime along with adding rows?

I have a aspx page consisting of a calendar button and a textbox.When we click calendar button then a calendar appears and the date which i select on calendar appears in textbox. Now what i want is to load the data from database according to the date selected and allow the user to edit it.And also i want to enable user to add rows at runtime. Do i need to create grid view at runtime?? Can somebody point me in a direction??
You don't need to create the gridview at runtime. You can define the gridview in the markup without having any data initially. You can set the calendar to autopostback and on the server side, capture the new date selected, grab the data based on that date and bind it to your gridview.
As far as editing the data, Gridviews already provide support for this and the amount of code that you need to write largely depends on how the datasource for the gridview is set up. If you use a SQLdatasource with the appropriate settings you practically don't have to write a single line of code besides the markup (Google: Gridview SQLdatasurce editing ASP.net).

Insert Records From GridView to another GridView Page

Can somebody help me?
I am developing a website using Microsoft Expression Web. My database is MS Access. My page extension is .aspx (ASP.NET)
I have two gridview:
Pending Records GridView should be under a PendingRecords.aspx page. I want this gridview to allow me to accept first all the requested records before they go straight under the Main Gridview. Of course, the gridview have "ADD" button. When I click the button, I want the records to be transfer in Main Records GridView.
Main GridView should be under a Records.aspx page. I want this gridview to display all the records that I already accepted in Pending Records Gridview.
Simple as that!
Thanks in advance!
one the button click event save the data from first gridview into the session and when load it again in the second gridview when page loads or reloads.
it will work if you don't have much data to move.....
hope will give you some idea.... :)

find controls from dynamically created table

i wrote a function to create dynamic table in code behind on selectedindexchanged of checkbox,
that is when user will check 2 checkboxex 2 tables will be generated with textboxes,
Then on button click i want insert values of these textboxes in database,
for that i want to find textbox using findcontrol,but i could not find it,
So i called same function of table creation on page load,
but then it shows error that textbox is having duplicate id
Plz tell me solution for this.
thanks
When you create dynamic controls, you need to recreate them on every postback.
The best place to do so is in the OnInit event handler. The problem with doing it in the SelectedIndexChanged event handler of the checkbox is that on postback they will not be re-created and can't be accessed.
See this article for details, and perhaps read up on the asp.net page life cycle too.
Add a div on the page with runat="Server" and give it an ID, div1 for example.
Add the table to this div but you should always write
div1.Controls.Clear();
at the first then add the table again to the div.

Why do I need to bind GridView on every postback to make click events from columns to work

Ok, i have a gridview and on page load, i dynamically add a column to it that contains a link control. this link control has a onclick event associated with it so that when its clicked, i want to do some processing. Now I have noticed that if I just bind the grid the first time (i.e. if(!IsPostBack) and have enableviewstate for the grid to be true, clicking the link in that column, doesnt trigger the onclick event. But if I bind the grid on every postback, everything seems to be working..does anyone know the reasoning behind it?
It happens because you're dynamically adding the column, so on every postback the column has to be created. What you may want to do is to look at Creating a Custom Column.
May be creating the row Id solves your problem. Check out this link and the post marked as answer.
http://forums.asp.net/p/1471128/3408069.aspx#3408069
Regards
Vinay

ASP.NET GridView - Editing Dynamic Template Columns

I have created a GridView whose columns are dynamically created based on my data source. I have implemented these columns by using the approach described here.Those columns display properly on the initial load. However, I need to implement commanding so that a user can edit / delete a row in the GridView.
At this point, I have implemented commanding as I would with a normal GridView. I have a TemplateField with an ItemTemplate that has LinkButton elements for edit and delete. The CommandName for each LinkButton is set to either Edit or Delete respectively.
Oddly, when a user clicks either the Edit or Delete link, the data in the GridView disappears. However, I have verified that I am in fact re-binding the data when one of these LinkButton elements is selected.
Can anyone provide some suggestions as to what the cause could be?
Thank you!
Here are good examples. You can figure out postback issue.
http://quickstarts.asp.net/QuickStartV20/aspnet/

Resources