473,472 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataGrid

Sakalicek
51 New Member
Hi all, could you please help me with my problem?

I have created DataGrid with Edit button and I want to have there also Delete button on each row.

But there should be some functionality like if user click on Delete, Delete link should change to two links "Yes" and "No". And than if user click Yes, row will be deleted.

I did it with setting Visible to true or false.
But I am not able to identify LinkButtons for Yes and No in DataGrid.

The main uestionn is, "how identify other objects in DataGrid row if I click on some object in that row.".

I need e.c. disable all the row before deleting.


Understand?

Thx 4 any help.

Zdenek.
Aug 30 '07 #1
7 1011
jhardman
3,406 Recognized Expert Specialist
moved to .NET forum
Aug 31 '07 #2
nateraaaa
663 Recognized Expert Contributor
Hi all, could you please help me with my problem?

I have created DataGrid with Edit button and I want to have there also Delete button on each row.

But there should be some functionality like if user click on Delete, Delete link should change to two links "Yes" and "No". And than if user click Yes, row will be deleted.

I did it with setting Visible to true or false.
But I am not able to identify LinkButtons for Yes and No in DataGrid.

The main uestionn is, "how identify other objects in DataGrid row if I click on some object in that row.".

I need e.c. disable all the row before deleting.


Understand?

Thx 4 any help.

Zdenek.
You will need to use a CommandName for each of your controls in that cell. Let's assume that you have 5 columns in your datagrid. The last column has 3 controls a Delete Button, a Yes hyperlink, and a No hyperlink. Assign a CommandName to each control.
Delete Button Command Name = "Delete"
Yes Hyperlink CommandName = "Yes"
No Hyperlink CommandName = "No"

Now for the datagrid add an ItemCommand Event to the datagrid. Go to properties and click the lightning bolt to see the events of the datagrid. Double click on ItemCommand.
Now in your code behind file add the following code to the new datagrid event:

Expand|Select|Wrap|Line Numbers
  1. //Make sure Yes and No linkbuttons are set to Visible = false;
  2. Button buttonDelete = (Button) e.Item.Cells[4].FindControl("nameofyourDeletebutton");
  3. LinkButton linkbuttonYes = (LinkButton) e.Item.Cells[4].FindControl("nameofyourYeshyperlink");
  4. LinkButton linkbuttonNo = (LinkButton) e.Item.Cells[4].FindControl("nameofyourNohyperlink");
  5. switch(e.CommandName)
  6. {
  7. case: "Delete"
  8. linkbuttonYes.Visible = true;
  9. linkbuttonNo.Visible = true;
  10. buttonDelete.Visible = false;
  11. break;
  12. case: "Yes"
  13. //call your delete proc here
  14. //Make sure to rebind the grid after this so that row will be removed from the UI
  15. linkbuttonYes.Visible = false;
  16. linkbuttonNo.Visible = false;
  17. buttonDelete.Visible = true;
  18. break;
  19. case: "No"
  20. //Don't delete just show grid again in normal state
  21. linkbuttonYes.Visible = false;
  22. linkbuttonNo.Visible = false;
  23. buttonDelete.Visible = true;
  24. default:
  25. break;
  26. }
This should get you on the right track.

Nathan
Aug 31 '07 #3
Sakalicek
51 New Member
Brilliant :D

Thanks a lot man.

Zdenek.


You will need to use a CommandName for each of your controls in that cell. Let's assume that you have 5 columns in your datagrid. The last column has 3 controls a Delete Button, a Yes hyperlink, and a No hyperlink. Assign a CommandName to each control.
Delete Button Command Name = "Delete"
Yes Hyperlink CommandName = "Yes"
No Hyperlink CommandName = "No"

Now for the datagrid add an ItemCommand Event to the datagrid. Go to properties and click the lightning bolt to see the events of the datagrid. Double click on ItemCommand.
Now in your code behind file add the following code to the new datagrid event:

Expand|Select|Wrap|Line Numbers
  1. //Make sure Yes and No linkbuttons are set to Visible = false;
  2. Button buttonDelete = (Button) e.Item.Cells[4].FindControl("nameofyourDeletebutton");
  3. LinkButton linkbuttonYes = (LinkButton) e.Item.Cells[4].FindControl("nameofyourYeshyperlink");
  4. LinkButton linkbuttonNo = (LinkButton) e.Item.Cells[4].FindControl("nameofyourNohyperlink");
  5. switch(e.CommandName)
  6. {
  7. case: "Delete"
  8. linkbuttonYes.Visible = true;
  9. linkbuttonNo.Visible = true;
  10. buttonDelete.Visible = false;
  11. break;
  12. case: "Yes"
  13. //call your delete proc here
  14. //Make sure to rebind the grid after this so that row will be removed from the UI
  15. linkbuttonYes.Visible = false;
  16. linkbuttonNo.Visible = false;
  17. buttonDelete.Visible = true;
  18. break;
  19. case: "No"
  20. //Don't delete just show grid again in normal state
  21. linkbuttonYes.Visible = false;
  22. linkbuttonNo.Visible = false;
  23. buttonDelete.Visible = true;
  24. default:
  25. break;
  26. }
This should get you on the right track.

Nathan
Sep 3 '07 #4
rohitbce
30 New Member
Hi
you have one more option to do like that just give one link button in datagrid Delete and that click event call the javaScript its only a one line code call confirm method so it will be ask yes or no............................
do it like that may be it will work
Thanks & regard
Rohit Jain
Sep 3 '07 #5
Sakalicek
51 New Member
Ok I know this oportunity but want to do it this way.
nevertheless, thank u for advice.

Hi
you have one more option to do like that just give one link button in datagrid Delete and that click event call the javaScript its only a one line code call confirm method so it will be ask yes or no............................
do it like that may be it will work
Thanks & regard
Rohit Jain
Sep 3 '07 #6
phanimadhav
78 New Member
how to place the conform to menu items
Sep 4 '07 #7
Sakalicek
51 New Member
Did you mean "how to place confirm" or what?
There could be placed validators.
E.g. CustomValidators or RequiredFieldValidators. Or you could add some code just into functions routed with the specific item in Grid.



how to place the conform to menu items
Sep 4 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
0
by: Richard Ryerson | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
7
by: Dave | last post by:
Are there any add-on products or samples available that can do the following in an vb.net datagrid I want to compare 2 rows in a datagrid - one row from one database and another row for another...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.