473,394 Members | 1,709 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,394 software developers and data experts.

Adding a confirmation pop when a row with a radio button is selected to be deleted

Hi There,
I have a label in a datagrid which I make it a input type = radio in
ItemDataBound so that radio buttons are shown in the datagrid.
This is how I have it...

ASPX...
<asp:Label ID="_selectedRBtn" Runat="server"></asp:Label>

ASPX.CS

Label _selectedProfile = (Label)
e.Item.Cells[0].FindControl("_selectedRBtn");
_selectedProfile.Text = "<input type=radio name='RBtnSelection' value="
+ (int)this._constraints.DataKeys[e.Item.ItemIndex] + ">";

And I check the
if(Request.Form["RBtnSelection"] != null)
{
int SelectedID = int.Parse(Request.Form["RBtnSelection"]);
}
to retrieve the Id selected..
I have a delete button which when clicked should pop up a confirmation
pop up and then only delete the particular row...I am unable to figure
out when and where I have to add the onclick attribute for it....like.
this._deleteBtn.Attributes.Add("onclick", "return Confirm_Delete();");
Can somebody please suggest me how to do this??

Thanks a lot.

Nov 19 '05 #1
5 1921
Samy,

Use the OnItemDatabound event of the datagrid, then in that event, identify
when an actual datarow is being bound, get the button object and cast it as
a button, and finally add your attribute. It would look something like this:

1.. Private Sub DataGrid1_ItemDataBound(ByVal sender As System.Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
2.. Try
3.. Dim itemType As ListItemType = e.Item.ItemType
4..
5.. If ((itemType = ListItemType.Pager) Or (itemType =
ListItemType.Header) Or (itemType = ListItemType.Footer)) Then
6.. Return
7.. Else
8.. '---You'll have to change the code that get's the link button to
reflect the proper zero based column index and control index:
9.. Dim button As LinkButton = CType(e.Item.Cells(3).Controls(0),
LinkButton)
10.. e.Item.Attributes.Add("onClick", "javascript:[your script here];")
11.. End If
12.. Catch ex As Exception
13.. '---Handle Exception
14.. End Try
15.. End Sub

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Samy" <sa************@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi There,
I have a label in a datagrid which I make it a input type = radio in
ItemDataBound so that radio buttons are shown in the datagrid.
This is how I have it...

ASPX...
<asp:Label ID="_selectedRBtn" Runat="server"></asp:Label>

ASPX.CS

Label _selectedProfile = (Label)
e.Item.Cells[0].FindControl("_selectedRBtn");
_selectedProfile.Text = "<input type=radio name='RBtnSelection' value="
+ (int)this._constraints.DataKeys[e.Item.ItemIndex] + ">";

And I check the
if(Request.Form["RBtnSelection"] != null)
{
int SelectedID = int.Parse(Request.Form["RBtnSelection"]);
}
to retrieve the Id selected..
I have a delete button which when clicked should pop up a confirmation
pop up and then only delete the particular row...I am unable to figure
out when and where I have to add the onclick attribute for it....like.
this._deleteBtn.Attributes.Add("onclick", "return Confirm_Delete();");
Can somebody please suggest me how to do this??

Thanks a lot.

Nov 19 '05 #2
Hi Justin,
Thanks a lot for your reply. The delete button (Image button) is
outside the datagrid. So I need to know when and where the statement
below has to be added. I don't wnat to show the pop up confirmation
when none of the radio buttons are selected from the datagrid.

Please let me know if I am not clear
Thanks.
Sam

Nov 19 '05 #3
this._deleteBtn.Attributes.Add("onclick", "return Confirm_Delete();");

Nov 19 '05 #4
Samy,

Ok, I misunderstood the first time. But I've got you now.

You'll have to add a detection in your script that pops up the confirmation
to check each radio button to look for a selected one.

That script will have to loop through each radiobutton and check if any are
selected. It would look something like this:
(I haven't tested the script below. I converted it from one I built for
verfying a checkboxlist count in a CheckBoxListRequiredFieldValidator I
wrote.
If you'd like the original script you could download the validator from my
site. It's free and comes as a Visual Studio.Net 2003 project with full
source code. Get it here:
http://www.aboutfortunate.com?page=c...tvalidatordemo.)

<script language="javascript">
<!--

function radiobutton_verification(clientID) {
var val = document.all[document.all[clientID].controltovalidate];
var col = val.all

if (col != null ) {
var radiobuttoncount = 0;

for (i = 0; i < col.length; i++ ) {
if (col.item(i).tagName == 'INPUT') {
radiobuttoncount += 1;

if (col.item(i).checked ) {
return true;
}
}
}
}
}

-->
</script>
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Samy" <sa************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi Justin,
Thanks a lot for your reply. The delete button (Image button) is
outside the datagrid. So I need to know when and where the statement
below has to be added. I don't wnat to show the pop up confirmation
when none of the radio buttons are selected from the datagrid.

Please let me know if I am not clear
Thanks.
Sam

Nov 19 '05 #5
Hi Justin,
Thanks for your reply. I really appreciate it.

Nov 19 '05 #6

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

Similar topics

1
by: Brian | last post by:
Hello all... I have a page that will be performing a search. The search consists of 3 radio button options. The first 2 will search the entire web through google and the site as indexed by...
3
by: jforena | last post by:
Hi, I am trying to create a javascript that will display a confirmation message when a user submits a form and has specifically selected a particular radio button. For example: <form...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
3
by: Alpha | last post by:
I have 3 radio buttons for include, exclued or 'select all' from the listbox items. If a user selects the 'Select All' button' then all items in listbox is hi-lited as selected. Now, when user...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
5
by: sweetpotatop | last post by:
Hi, I have a page written in C# asp.net, which allow users to select and delete records. Once user selects the record to be deleted, I will confirm with the user, something like "Are you sure...
8
by: crayfiss | last post by:
Hi, firstly I am a total freshie in all this. From what I have gathered on the web and this forum, I finally managed to get my form up. I have a set of radio buttons with values to it and a select...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.