Solved

onclientclick question for gridview

Posted on 2007-03-22
1
429 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…

730 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