Overriding The Editindex After A GridView Update?

Feb 12, 2010

I have a GridView control hooked up to a datasource that I allow row editing on. I use the standard edit/save/delete buttons that point to the Update, Cancel, and edit GridView commands.

I would like to add an additional button, "Next" inline with the save/cancel button. This would function the same as the save button, but would also add an additional row to the grid, and place that row into edit mode. To do this, I've added code to the Updated event of the GridView, which adds a new record to the db, rebinds the grid, and sets the editindex. This seems work, but the grid does not actually return in edit mode. I stripped out the new record code and simply left the statement to set the editindex, but the grid still will not stay in edit mode.

Is it possible to force the grid to stay in edit mode in this scenario? It appears that unless you set the cancel property of the GridViewUpdatedEventArgs, the Grid is going to flip to view mode. I don't want to set the cancel property in this case, because I want the GridView to trigger my datasource object to save the record.

If this doesn't work, it appears that I will need to allow the update to occur normally, return to the client, and then send another server request to add the record. I'd prefer not to do it this way, I would like to perform the necessary operations in context of one roundtrip.

Here's what the code (simplified) looks like:

protected void Button1_Click(object sender, EventArgs e)
{
// Works Fine
this.sampleDataSource.Insert();
this.sampleGridView.DataBind(); [code]...

View 3 Replies


Similar Messages:

.Net GridView EditIndex Race Condition?

Oct 12, 2010

This is a bit of a hypothetical question that has sent me off down the garden path... Say I have a gridview that I'd like to edit... given a method that binds the data..

private void BindGridFirst() {
var data = new List<string>() {
"A","B","C","D","E","F"[code]...

Now presume that I'm looking at this page, and another user has come along and made some changes to the underlying data, and I now go and click the edit button to edit D...

The edit method is pretty straight forward:

protected void RowEdit(object sender, GridViewEditEventArgs e) {
gridView.EditIndex = e.NewEditIndex;
BindGridSecond(); [code]....

It's exactly the same, but the data is now changed. Once the UI updates, the user is now in edit mode against row C.Not what the user expected or wanted. How should this scenario be handled to avoid such an issue?

View 2 Replies

Overriding Alternatingrowstyle In Gridview

Feb 1, 2011

I have a GridView which uses the Alternatingrowstyle property, but I also would like to higlight each row when the user Edit the row, but using this code, it only highlights the rows that don't have the Alternatingrowstyle.

protected void gv_RowEditing(object sender, GridViewEditEventArgs e)
{
gv.Rows[e.NewEditIndex].BackColor = System.Drawing.Color.Yellow;
gv.EditIndex = e.NewEditIndex;
if (e.NewEditIndex % 2 == 0)
{
gv.Rows[e.NewEditIndex].BackColor = System.Drawing.Color.Yellow;
}
}

View 2 Replies

Forms Data Controls :: How To Capture The Value Of Dropdownlist On Editindex

Jan 22, 2010

I have a dropdownlist control in grid.On edit item of the grid I have to find the value of the dropdwolist and set it accordingly. tell the code.Its just one line code but I am not able to find the correct way.

View 2 Replies

C# - Having Two Page_Load Without Overriding?

Jul 7, 2010

I have a class named PageBase inheriting from ASP.NET Page. I want to do something in PageBase's Page_Load.All pages in my application have their logic done on their Page_Load. I'm thinking of a way that Page_Load of both of PageBase and other pages run without having to override Page_Load in pages. Is it possbile?

View 1 Replies

ADO.NET :: Overriding A EF Object Property Set?

Dec 7, 2010

I've generated an entity framework class to handle my users from a custom db table. Now I'd like to override the password property of the EF object to Encrypt the value when it is set. From what i understand of MVC this should be done in the model where the EF object lives. I am able to do this easily in the controller but that doesn't seem like the most appropriate place as it will lead to duplicate code anywhere that needs to edit this user class. Is extending the partial class generated from EF possible for generated DB column properties?

View 1 Replies

C# - IIS Overriding Custom 404 Error Page

Feb 18, 2011

I am trying to create a 404 error page and currently I have all of the following/tried all of the following to try and accomplish this. When the user types in :

http://name/something.aspx

It works just as its supposed to. But if the user types in:

http://name/NotAFile

with no .aspx then IIS7 takes matters into its own hands and I get the lovely error page that IIS7 comes with. The goal is that the site redirects with only a 404 status code (so not a 200, or a 302 redirect). I have tried in both the web config with:

<customErrors mode="On" defaultRedirect="~/error/Default.aspx redirectMode="ResponseRewrite">
<error statusCode="404" redirect="~/error/NotFound.aspx" />
</customErrors>

This works for the url with a .aspx file extension but not for no extension. Same with this approach in the global.asax

void Application_Error(object sender, EventArgs e)
{
var serverError = Server.GetLastError() as HttpException;
if (serverError != null)
{
if (serverError.GetHttpCode() == 404)
{
Server.ClearError();
Server.Transfer("~/error/NotFound.aspx");
}
Server.Transfer("~/error/Default.aspx");
}
}

The same results are present for this :( My final attempt was to apply this to the web config:

<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>

With this I just get a plain white screen with nothing on it...

View 1 Replies

MVC :: Custom Exceptions - Overriding OnException?

Jun 18, 2010

I've created a custom exception that inherits from Exception. I initially tried using the HandleError attribute with it, but too many things to list went wrong with that. I read about overriding OnException in a base Controller class, and decided to give that a try. This is the code:

[Code]....

This works, but I have a few questions. First, does an error page have to derrive from 'System.Web.Mvc.HandleErrorInfo'? I added a few new properties to my exception, and thought I'd be able to send it as a model to the error View where I could display those properties as usual when populating a View, but when I changed the type that the error View derrives from I get the yellow screen of death.

Also, I read that the above code would cause MVC to look first in the Views folder that correspondss to the controller that threw the exception. This was not the case. I placed the Error.aspx file in that Views folder and was treated to the YSOD again. I simply cut and pasted the file into the base shared folder and it worked. I am using Areas, and wonder if that could be a bug.

The last question I have is about the exception object as it's thrown. After throwing an exception, in the OnException method I thought I'd be able to see and manipulate the exception, but if that is possible I don't know how. What I would really like to do is to treat the exception object like any other object. I want to intercept its handling in the OnException method and send it to a View.

View 1 Replies

Architecture :: Overriding Aspx Pages - Best Design?

Jan 25, 2011

I would like to provide my client with a aspx pages, with code behind provided, etc. But in some cases they will want to write their own markup - I'm thinking of having 2 directories [siblings of each other], one for the pages I provide, and the other for their custom markup. At page serve time, check to see if the client wrote their own markup and if so use it. Otherwise use the default provided.

In a nutshell I would like for my clients to be able to modify the pages I provide, but if they blow it up have a very easy way to back it out. Or to put it in a more positive light, allow them to override my pages easily.

View 5 Replies

Overriding The Now() To Adjust Server Local Time?

Feb 27, 2011

As the server of my website is located in a different timezone, is there a easy way to override the server local time by a setting in either web.config or global.asa?I could of course just use .AddHours() in all my .now() statements, but as this problem occured recently when I moved the site and that the .Now() syntax is used a number of times in the application I was looking for a another solution than changing my code everywhere I've used this syntax.

View 2 Replies

Security :: Overriding A Method From Membership Class ?

Feb 13, 2011

I'm new to MVC and I have a question and I need your inputs.I have this portion of code inside a method (let me just call this MyMethod):

[Code]....

where I am simply using the default CreateUser method from default Membership class to create a new user. This method simply adds the user on the default membership table. Now I have another table which I call userDetails table and I am hoping to add additional information related to the user recently added on the membership table.I can simply add more codes inside MyMethod to do the above logic of adding the additional information to another table. However I was thinking that if I do this... and I delete the user using the ASP.Net Web Application Administration Tool, I may end up with orphan entry on my userDetails table after the user is deleted from the membership table (since the administration tool wouldn't know MyMethod and use the default method from Membership class).So is there a way I can override the CreateUser method from the System.Web.Security.Membership class such that it goes through this flow?

1. invoke the original or base CreateUser method (the user is now created during this step)

2. determine user_id of the newly-added user on membership table.

3. add more user-related information on another table example: userDetails table.

This way, every time I call the CreateUser method it automatically adds the necessary entries on the membership and userDetails tables.If I create my own membership class inheriting from the original class, it would mean a lot work rewriting lots of methods when in reality what I'm trying to achieve is only adding additional information related to the user. I tried modifying the default membership table from the provider database but I get and error during the user-creation process. This gives me the impression that I am not allowed to modify the existing tables... which would lead me to creating a custom provider.

View 2 Replies

Web Forms :: Difference Between Page_Init() And Overriding Oninit()

Dec 31, 2010

explain the diference between these Page_Init() and OnInit() events and when we should use which one?

View 2 Replies

Overriding The Default 'No Data' Message In MVCContrib Grid?

Oct 21, 2010

Is it possible to override the default 'There is no Data available' message in MVCContrib Grid with a custom message?

View 1 Replies

C# - Overriding SQLMembershipProvider / Adding Few Extra Methods To Deal With The Roles By Using LINQ?

May 27, 2010

Is there built in methods into .net framework to do the following:

Get role GUID from user name/user GUID
Get role name from role GUID

So far I have been sending queries to the asp_roles and asp_users tables to obtain that information and I'm wondering if there is a nicer way of doing this?

I have the following methods that I store in the ASPUtilities class:

getRoleGUID(guid userGuid) { LINQ joins }

getRoleGuid(string userName) { LINQ joins }

getRoleName(guid roleGuid) { LINQ joins }

EDIT:

I have just looked into extending SQLMembershipProvider examples.

Few examples completely override the SQLMembershipProvider, but I think what I'm interested is just adding few extra methods to deal with the roles by using LINQ. Is this feasible?

View 1 Replies

DataSource Controls :: Update The Data Of A Database Through A Gridview Update Button?

Apr 19, 2010

i want to update the data of a database through a gridview update button

how can i attach a dataconvertion like this

[Code]....

View 1 Replies

Forms Data Controls :: Update Multiple Rows Of Gridview On Click Of Update Button?

Jul 10, 2010

I want to update multiple rows of gridview (only price field. for that i have added textbox) on click of update button which is outside of gridview.I have done following way

<asp:LinkButton ID="lnkUpdate" CssClass="BlueButton" runat="server" OnClick="lnkUpdate_Click">Update</asp:LinkButton>

[Code]....

Up to this its working fine but when no textbox updated then no need to go in for loop so i am looking for confiramtion before updating rows please help me how to do that becausei am less aware with javascript. another problem is textbox value disappear when page index changed how i can retain that values.

View 2 Replies

Forms Data Controls :: Gridview Update Mode Is Not Ending After Clicking On Edit Then Update?

Mar 23, 2011


[Code]....

View 8 Replies

Forms Data Controls :: Update A Row Using The Update Functionality Of Gridview?

Jun 28, 2010

When i try to update a row using the update functionality of Gridview it updates all the rows rather then updating that specific row which is in edit mode.

[Code]....

View 1 Replies

Data Controls :: Update GridView Row On Update Button Click

Jul 31, 2012

I have a query . I want to edit the grid view columns in which user click the edit button he will edit the column in the grid and after that i want to add update button so that when he clicks on updates button after editing the row. The row will be updated and the grid will show you the new update row.

Here is my following piece of code.

<asp:GridView ID="noticeDetails" runat="server" BorderWidth="1px" AutoGenerateColumns="false" PageSize="10" Width="100%" CellPadding="10"
AutoGenerateEditButton="true" onrowediting="noticeDetails_RowEditing" >
<Columns> <asp:TemplateField HeaderText="CampaignIDRange">
<ItemTemplate> <%# Eval("CampaignIDRange")%>

[Code] ....

Basically grid is about that when user enter values intothe grid, the values will show in to the grid upon click button.I added edit button it works fine but it will incomplete without update button method ... 

View 1 Replies

C# - Gridview Update Changing Update Parameter?

Oct 20, 2010

I have a Gridview where I can modify the Time portion of a DateTime field. The update method is working well, except for one thing:The field should only allow the time portion, e.g 08:23:09 but on the Database it saves it as a full DateTime, e.g 10/18/2010 08:23:09 AM. The problem is that upon editing, instead of adding the existing Date portion, it adds the current Date portion. So if I am editing the item from the last example into 08:25:09 instead of adding it as 10/18/2010 08:25:09 AM it adds it as 10/20/2010 08:25:09 AM which is obviously undesired behavior.Here's how I am doing the update:

protected void grvOutHour_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridView grvOutHour = (GridView)this.grvReport.Rows[grvReport.EditIndex].FindControl("grvOutHour");
TextBox txtBox = (TextBox) grvOutHour.Rows[e.RowIndex].FindControl("txtEditOutHour");

[code]...

View 1 Replies

MVC :: Configuring Html.ValidationMessageFor(), Or Overriding Html.TextBoxFor()

Jan 3, 2011

[Code]....

The model has a required attribute for the first name property:but I would like to make this happen automatically if the property has the CustomRequiredAttribute. Is there a way to override the Html.TextBoxFor() and check for the attribute on the given property? Or is there another way to accomplish this behaviour?

View 3 Replies

Forms Data Controls :: Gridview Update / Delete Command Like A Update Command?

Apr 26, 2010

how would i do my Gridview delete command like a update command?

im using a datasource... and my delete command is like my update command... so i can change the status into "INACTIVE"...

DeleteCommand="UPDATE ACCOUNT_MAINTENANCE SET am_status = 'INACTIVE' WHERE (accmain_no = @accmain_no)"

UpdateCommand="UPDATE [ACCOUNT_MAINTENANCE] SET [account_type] = UPPER(@account_type), [min_deposit] = @min_deposit, [min_capital] = @min_capital WHERE [accmain_no] = @accmain_no"

when i press my delete command at gridview... the status changed into "INACTIVE" but when i refresh or press f5... it automatically update the status into "INACTIVE" also...

View 3 Replies

C# - WCF Some Clarification On "overriding"?

Apr 1, 2010

Recently I faced few interview questions.The interviewer asked the to give the detailed answer.1)Can we override a WCF service (Its is not OOPS overriding) ?.Explain the reason on either end. (WCF Related).2)Can we override Page events (Page_Load())?.Explain reason.(ASP.NET related).3)What is the primary responsibility of Pre_Init( page) event ,apart from user preference setting,skinning?4) Can we override Static methods.Explain the reason.(C# related)

View 1 Replies

Forms Data Controls :: How To Update Parent Gridview After Updating Child Gridview

Dec 14, 2010

I have a parent gridview which has a child gridview in the itemsTemplate. Both are binded to different SqlDataSources. I can successfully update and delete rows in the child gridview. After updating in the child gridview, some related data in the parent gridview are not updated automatically. So i have placed ParentGridview.Databind() in the rowupdated event of child gridview. But it doesnt look working.

How can i accomplish this?

View 4 Replies

Forms Data Controls :: Loop Gridview To Update Values In Gridview To Stored Procedure?

Jan 14, 2010

I would like to ask a question on the visual basic codes to loop the gridview to retrieve the values and based on the values, it will be provided as parameters to update to the database table using stored procedure.

Firstly, I have a gridview named grvProduct. The page (ui) will be loaded with data from the database with the use of stored procedures. And only certain values can be edited through the use of template in gridview. So based on those edited values, I'm supposed to pass these values as parameters to the stored procedure which will then update a database table.

Let say, I have 3 records retrieved from the database and displayed in the gridview. And I would like to edit a values in the 3 records, how do I do batch update and pass those parameters to the stored procedure? I went to debug and step through the visual basic codes and realised there were too many arguments specified because I actually loop the gridview.

Below is my visual basic codes:

[Code]....

Below is my Stored Procedure code:
[Code]....

I believe it is the error in the looping of the gridview which results that I could not batch update the data/values.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved