Solved

onclientclick question for gridview

Posted on 2007-03-22
1
416 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 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