Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Adding a confirmation pop when a row with a radio button is selected to be deleted

Reply
Thread Tools

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

 
 
Samy
Guest
Posts: n/a
 
      10-27-2005
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.

 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-27-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.
>



 
Reply With Quote
 
 
 
 
Samy
Guest
Posts: n/a
 
      10-27-2005
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

 
Reply With Quote
 
Samy
Guest
Posts: n/a
 
      10-27-2005
this._deleteBtn.Attributes.Add("onclick", "return Confirm_Delete();");

 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      10-27-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
Samy
Guest
Posts: n/a
 
      10-28-2005
Hi Justin,
Thanks for your reply. I really appreciate it.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a confirmation pop-up window for datagrid delete Elton W ASP .Net 0 05-15-2005 08:47 PM
"Deleted row information cannot be accessed through the row." WHY!! Mohammad Ali via DotNetMonster.com ASP .Net 0 04-16-2005 07:17 AM
My addnew row button is only adding one row? Luis Esteban Valencia ASP .Net 0 03-23-2005 04:03 PM
submit confirmation with radio button selected jforena@hotmail.com Javascript 2 02-09-2005 07:19 PM
Radio button List problem: How to find value of Radio button list's Selected Item using javascript?? Hiten ASP .Net Web Controls 1 05-26-2004 10:32 AM



Advertisments