Solved

onclientclick question for gridview

Posted on 2007-03-22
1
421 Views
Last Modified: 2012-05-05
i have a gridview with checkboxes for each row. I have a button for update on a checked row (I only want to let people update one row at a time). How can I add a confirm update popup or something similar for a checked row with a particular string in a field?

i.e.
checkbox    product     name    status
[]                 p2              bob      active
[]                 p4                          pending

if someone checks the second row I don't need an update confirmation, but if someone checks the first row I'd like a confirmation since the name field is populated....I can't seem to tweak the javascript for the onclientclick to check for the name field populated or not... i get the confirmation alert for all checkboxes by default... any suggestions?
0
Comment
Question by:acdagirl
1 Comment
 
LVL 9

Accepted Solution

by:
bele04 earned 500 total points
ID: 18777790
you can try adding the javascript on the RowDataBound event of the GridView to check if the name column is null/empty or not.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if ( e.Row.RowType == DataControlRowType.DataRow )
        {
            if ( !String.IsNullOrEmpty(e.Row.Cells[2].Text) )
            {
                CheckBox cb = e.Row.FindControls("<name of your checkbox>") as CheckBox;
                cb.Attributes.Add("onchange", "javascript:alert('hey');");
            }
        }
    }
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question