473,412 Members | 2,994 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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 1112
use this datagrid event to find which button was click.Info should be in
DataGridCommandEventArgs
DataGrid1_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

"dm**********@yahoo.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(object sender, System.EventArgs e)
{
if (!IsPostBack )
{
//You need to retrieve the data and bind to the datagrid
BindDataGrid();
}
}
private void DataGrid1_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataRow dr = Ds.Tables[0].Rows.Find(e.Item.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.DataSource = Ds;
DataGrid1.DataBind();
}

"dm**********@yahoo.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
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...
2
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...
5
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
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...
1
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...
2
by: tomcarr1 | last post by:
In this walkthrough on "Allowing Users to Delete Items in a DataGrid Web Server Control" at: ...
9
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...
4
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...
9
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.