Solved

onclientclick question for gridview

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now