473,804 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datagrid delete with 2 users

Hi,

I have a datagrid hypothetically with this data:

id | text | link
-------------------------------
1 | first row | delete button
2 | second row | delete button

I have 2 users with 2 DIFFERENT browser instances.

I have a problem.

If user 1 deletes row with id 1, his screen refreshes and he gets:

id | text | link
-------------------------------
2 | second row | delete button
However now, user 2, still has the previous screen:

id | text | link
-------------------------------
1 | first row | delete button
2 | second row | delete button

User 2 tries to delete row 1 within a few seconds of user 1 deleting
row 1.

However when user 2 does this user 2 deletes row 2 and gets!

id | text | link
-------------------------------
To select the row to delete I do this:
string selectedRow = e.Item.Cells[0].Text;

However for user 2 it picks up the second row which is incorrect. How,
do I tell in .net to pick up the current row, so for each user they
pick up the current row. It looks like its posting back. Is there a
way to capture which button was clicked because onpostback I'm binding
the grid repeatedly. I want it not to bind the grid if delete is
pressed.

Thanks

:D

Nov 19 '05 #1
3 1134
use this datagrid event to find which button was click.Info should be in
DataGridCommand EventArgs
DataGrid1_Delet eCommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)

"dm**********@y ahoo.com" wrote:
Hi,

I have a datagrid hypothetically with this data:

id | text | link
-------------------------------
1 | first row | delete button
2 | second row | delete button

I have 2 users with 2 DIFFERENT browser instances.

I have a problem.

If user 1 deletes row with id 1, his screen refreshes and he gets:

id | text | link
-------------------------------
2 | second row | delete button
However now, user 2, still has the previous screen:

id | text | link
-------------------------------
1 | first row | delete button
2 | second row | delete button

User 2 tries to delete row 1 within a few seconds of user 1 deleting
row 1.

However when user 2 does this user 2 deletes row 2 and gets!

id | text | link
-------------------------------
To select the row to delete I do this:
string selectedRow = e.Item.Cells[0].Text;

However for user 2 it picks up the second row which is incorrect. How,
do I tell in .net to pick up the current row, so for each user they
pick up the current row. It looks like its posting back. Is there a
way to capture which button was clicked because onpostback I'm binding
the grid repeatedly. I want it not to bind the grid if delete is
pressed.

Thanks

:D

Nov 19 '05 #2
I don't understand what you mean. I need to find out on POSTBACK.
Please provide a brief sample if possible.

Thanks in advance.

:D

Nov 19 '05 #3
Let me know if this helps.

private void Page_Load(objec t sender, System.EventArg s e)
{
if (!IsPostBack )
{
//You need to retrieve the data and bind to the datagrid
BindDataGrid();
}
}
private void DataGrid1_Delet eCommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
DataRow dr = Ds.Tables[0].Rows.Find(e.It em.Cells[0].Text);
dr.Delete();
BindData();
}
private void BindDataGrid()
{
SqlConnection Conn = new SqlConnection(" string connection");
SqlDataAdapter Da= new SqlDataAdapter( "query", Conn);
Conn.Open();
DataSet Ds= new DataSet();
Da.Fill(Ds);
DataGrid1.DataS ource = Ds;
DataGrid1.DataB ind();
}

"dm**********@y ahoo.com" wrote:
I don't understand what you mean. I need to find out on POSTBACK.
Please provide a brief sample if possible.

Thanks in advance.

:D

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4419
by: JR | last post by:
Hello, Does anyone know how you can prevent a row full of 'null' values from being added to the datagrid when a user hits the delete key, deleting the word (null) which represents the default value of 'null'? Here's a simple way to reproduce this problem: 1) Add a datagrid to a winform 2) Put this code into the Form1_Load event and run it.
2
2221
by: Mark Rae | last post by:
I've inherited an ASP.NET app and have been asked to fix the following problem with a page which is used to display and/or delete records from a database. When the page loads, it displays a list of the 26 letters of the alphabet as hyperlinks which the users then click to return records beginning with that letter, displayed in a DataGrid. The first column of the DataGrid contains a LinkButton which, when clicked, calls the Delete method of...
5
344
by: I am Sam | last post by:
I have a rather complicated problem I need to sort out and wonder if anyone can assist me. The ingredients: Two DropDownList Controls One DataGrid Purpose of Page:
2
6139
by: John Huang | last post by:
I would like to use datagrid's keydown event to capture the "Ctrl+D" when users press this key. But it did not work. What did I miss? (I have already set the form keypreview to true) Private Sub grdInCategory_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles grdInCategory.KeyDown If e.Control And e.KeyCode = Keys.D Then If MsgBox("Are you sure to delete the record ?", MsgBoxStyle.YesNo) =...
1
1457
by: thebison | last post by:
Hi all, I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my database has been made in MSDE. I have a DataGrid, and have inserted a delete link button into it through Property Builder. My Delete method works fine, however I would like to insert a JScript popup to confirm, as otherwise users can just
2
1776
by: tomcarr1 | last post by:
In this walkthrough on "Allowing Users to Delete Items in a DataGrid Web Server Control" at: ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbtskallowinguserstodeleteitemsindatagridwebcontrol.htm it leaves out some very important code. Here is what it gives you: ' Visual Basic Private Sub DataGrid1_DeleteCommand(ByVal source As Object, _ ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
9
2734
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
4
7505
by: mamun | last post by:
Hi All, I have the following situation and am looking for answer in C#. I have a datagrid and putting checkbox next to each record. In the header I have a Delete button. I want users to checkchekboxes and click the Delete button. That will show a confirmation dialog message with the items they choose to delete.
9
5013
by: rn5a | last post by:
A DataGrid is populated with the records existing in a database. Each of the row in this DataGrid has a ButtonColumn. Assume that the DataGrid displays 10 records (i.e. 10 DataGridItems/rows). Each row in the DataGrid (of course, except the Header & the Footer) is accompanied by a ButtonColumn i.e. there are 10 Buttons in the DataGrid. The Buttons that get rendered by the ButtonColumns - how do I get the ID of each of these Buttons?
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.