.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


Similar Messages:

Treat Race Condition Of Session In Web Application?

Apr 3, 2010

I was in a ASP.NET application has heavy traffic of AJAX requests.Once a user login our web application, a session is created to store information of this user's state. Currently, our solution to keep session data consistent is quite simple and brutal: each request needs to acquire a exclusive lock before being processed.

This works fine for tradition web application. But, when the web application turns to support AJAX, it turns to not efficient. It is quite possible that multiple AJAX requests are sent to server at the same time without reloading the web page. If all AJAX requests are serialized by the exclusive lock, the response is not so quick. Anyway, many AJAX requests that doesn't access same session variables are blocked as well.If we don't have a exclusive lock for each requests, then we need to treat all race condition carefully to avoid dead lock. I'm afraid that would make the code complex and buggy.

So, is there any best practice to keep session data consistent and keep code simple and clean?

View 2 Replies

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

Windsor And .net MVC Singleton Race Conditions?

Dec 14, 2010

Quick question regarding the use of Singleton lifestyle in Windsor, and Asp.Net MVC. If the following class is registered as a singleton am I correct in thinking that I will have a race condition?

public class UserMapper : IMap
{
public void Map(MyDto dto, MyDomain domain)[code]...

View 1 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# - Show Data In Gridview Using Condition

May 19, 2010

I want to check a condition in a grid view e.g.

if(loginid.equels('admin'))
query = select * from memberlist;
else
query = select * from memberlist where memberid like 'operator%';

depending on the query ther grid view will display the listof members and also where to put this code in .cs or .aspx and how?

View 2 Replies

How To Put Condition In Gridview Bound Field

Nov 23, 2010

here my code-

<asp:BoundField DataField="DayOfTheWeek" HeaderText="Day" ItemStyle-CssClass="Itemstyle"/>

from my collection entity I am getting DayOfTheWeek like 1,2...7. 1 for monday , 2 for tuesday like that. Where should I place condition so that in grid view it would display day name rather than corresponding code.

View 1 Replies

Change GridView Row Color Based On Condition In C#

Feb 19, 2011

I want to change a particular row color of gridview based on some condition, i am using ASP.NET with c#.

View 2 Replies

C# - How To Check The CheckBox In A GridView Based On Condition

Jan 11, 2011

I have four textbox fields for ItemName, ItemDescription, Length and Quantity.

One radiobuttonlist and its listitems are FixedLength and Random Length.

One button field called Submit and one gridview.

In the GridView I have 4 bound columns and 1 template column such as ItemName, ItemDescription, Length, Quantity and IsFixed_f(flag field). I have added one checkbox in the GridView's Template column for the IsFixed_f field.

After entering all textbox fields, I have to select either one listitem in the radiobuttonlist(FixedLength or RandomLength). After completing these things. If I enter the Submit button, all the values in the textbox to be displayed under the GridView's corresponding column name and checkbox to be checked if FixedLength listitem is selected otherwise the checkbox.checked should be false. How to do this?

In the Button Click event, i have used like this

[code]....

View 3 Replies

C# - Display Only The Records That Satisfy The Condition In A Gridview?

Nov 9, 2010

I am inserting a new record in a form that has two textboxes txtName, txtAge and I am using an ajax calender extender txtDOB and a gridview control gdvDisplayRecords with 3 fields name, dob and age. So when i select any date from ajax calender extender, the gridview must display only those records from the database which have same DOB before i try to add this new record.

View 1 Replies

Hide A Column Of GridView Based On A Condition?

Feb 11, 2011

I want to hide a column of GridView based on a condition. How can I access the column in C# code?

if() // condition
{
// Disable code here. ?????
}

View 2 Replies

C# - How To Write Condition On Client Side Within Gridview Itemtemplate

Jul 13, 2010

I need to write condition on client side within GridView itemtemplate.

<% if(Eval("item").Contains("keyword"){%>
<img src='<# Eval("imagepath") %>' />
<%}
else if(Eval("item").Contains("keyword2")){
%>

View 3 Replies

Data Controls :: How To Highlight GridView Row Based On Condition

May 25, 2012

I want to higlight the background color based on condition

E.g. I have a column like 

name       rate

rafi           100
ravi           0
karthick   300

Here rafi and karthick should display the background color

ravi should display the whitecolor

View 1 Replies

Data Controls :: Change Color Of Particular GridView Row On Some Condition?

Nov 27, 2013

There is a gridview, in that i have 5 columns. Data is coming from Database inside gridview.

I want to change the ForeColor of 5th column's particular rows in gridview according to condition.

The data in 5th column is coming from Database. I want to change the ForeColor of that column's particular rows according to condition.

here is gridview data:-

Station Name
State
Gate1
Gate2

[Code].....

I want to change the color of 5th column("DangerValue") rows only according to condition.

View 1 Replies

Data Controls :: How To Use IF ELSE Condition In EVAL Function In GridView

May 7, 2015

<asp:TemplateField HeaderText="Is Activate ?">
<ItemTemplate>
  <a href="#" onclick='fnViewRemarksTest(<%#DataBinder.Eval(Container.DataItem,"CustomerId")%>)'><%#Eval("IsActivated ")%></h3></a>
</ItemTemplate>
</asp:TemplateField>

Is Activated is a boolean data type column in Sql.

I want to Show that, when IsActivated is true text will be "User Is Active" and when false , the text will be "User Is not activate" ...

View 1 Replies

Forms Data Controls :: How To Change The Color Of The Value In Gridview Using Condition

Jun 17, 2010

[URL]

if the ABOVE pic is not visible CLICK HERE to view

I want to change the colors of the values from the table SALARY

if the salary is > 20,000 i want to change it to GREEN color

if < 20,000 then it should show RED color

View 4 Replies

Forms Data Controls :: Set Certain Columns In Gridview Invisible Upon Certain Condition?

Jul 2, 2010

I have a gridview that is being populated off of a query that has joins in it. It works fine. However, I want to display one record of all information but then blank out all colunmns accept 1 for the other 3 records that it is picking up. In other words, right now, all three records have duplicate info in them accept this one column. can this be done? Can I somehow blank out other columns based upon what is in the single column? This is all being done in a gridview. I realize it would do a master detail type scenario but I want all of this information to display without someone having to click on a field or anything.

View 4 Replies

Forms Data Controls :: Display Image In Gridview According To Condition?

May 8, 2010

I have a gridview bound to object data source & in its item template i have some labels and one image control and I have a [Status] column in database that store either true or false in bit format . now what i want is if value in status column is true then image control's ImageUrl property should use image ~/images/Show.jpg and if it have false value then it should show ~/images/Hide.jpg.

currently i am using this code it works fine but i think there must be some good better way to achieve this goal. here is the code that i m using

if (e.Row.RowType == DataControlRowType.DataRow)
{
Image img = (Image)e.Row.FindControl("ImgCatStatus");
if (img.AlternateText == "True")
{
img.ImageUrl = "~/images/Show.jpg";
}
else
{
img.ImageUrl = "~/images/Hide.jpg";
}

i have bound the alertenateurl to <%#Bind('Status')%> and performing evaluation based on value it contain

View 7 Replies

Forms Data Controls :: Hide Gridview Row Based On Condition?

May 10, 2010

I have one asp.net gridivew where i have written some code and bind it.. itz working fine now my requirment is when ever any gridview row which conatin column 3rd zero(0) i want to hide tht row ..

View 2 Replies

VS 2013 - Removing Hyperlink From Gridview Column Based On Condition

Mar 24, 2016

I have a gridview, in which one of the columns [unitid] is a link that opens up other gridviews. When the [downtime] column is equal to '0', i'd like the link in [unitid] to be removed, and just show that field as text. Here's my code for the gridview:

<asp:GridView ID="gvUnitSummary" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" HorizontalAlign="Center" Width="100%"
Font-Size="Medium" DataSourceID="sdsUnitSummary" DataKeyNames="unitid" EnableModelValidation="True"
EnableViewState="False" >
<AlternatingRowStyle BackColor="#CDDBB4" />

[Code] .....

View 4 Replies

Data Controls :: Change GridView Row Color Based On Condition

Jul 26, 2013

I want to change the color of particular gridview rows with an image in one row, based on condtion. How to achieve it.

View 1 Replies

Data Controls :: How To Display Different Row Colors Based On Condition In Gridview

Jul 19, 2013

how to display row values based on condition in grid view control and how to display different row colors based on condition in grid view.

View 1 Replies

Web Forms :: Hide Specific Row Cell From GridView Based On Some Condition

Aug 3, 2012

I have a gridview which displays a list of submittted applications with a column that contains an edit link.

<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:LinkButton ID="lnkBtnEdit" runat="server" CommandArgument = '<%# Eval("appID")%>' Text = "Edit" OnClick = "editApp" />
</ItemTemplate>
</asp:TemplateField>

I want to hide the link button if the status (value 1 or 0) of the form is set to 1. Here is the code I am trying to use.

Protected Sub gv1_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
'get the cell cell value
Dim status As Integer

[code]....

I think my mistake lies in getting the status value (as it ouputs 0 for every application).

View 1 Replies

Data Controls :: How To Blink GridView Row Based On Some Condition Using JQuery

May 7, 2015

I have to write this code to blink particular rows of gridview based on some conditions I found below link which actually does blink but after we click the row. URL...I need that the row should blink as soon as the web page loads.I also tried using the jquery as in below link but it is also giving error as.URL...

View 1 Replies

Data Controls :: How To Change Color Of Particular Cell Of Gridview As Per Condition

Feb 25, 2016

I have a gridview that shows Gender column, My requirement is to set the color of Gender column with following condition

if Male-->Color is Red

if Female-->Color is Yellow

how should i do this ?

View 1 Replies







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