dat grid error with javascript


I am using  ajax controol tool file upload to uplaod an image and then populate that image in a datagrid.

However what happens if it is the first time that I am uploading something then I get an error
"Unhandled Exception 'dlV' is undefined"

I am assuming this is because it can not find the datagrid

Code below

Please help

<script type="text/javascript" language="javascript">
        function UploadComplete(sender, args) {

            var fileupload = document.getElementById("asyncFileUpload1");
            if (fileupload != null) {
                document.getElementById("asyncFileUpload1").outerHTML = fileupload.outerHTML;


            document.getElementById('lblStatus').innerText = 'Uploading Completed.';


aspx page
               <cc1:AsyncFileUpload ID="asyncFileUpload1" runat="server" UploadingBackColor="LightGray"
                    CompleteBackColor="Lime" OnUploadedComplete="asyncUploadComplere" UploaderStyle="Modern"
                    ThrobberID="Throbber" OnClientUploadComplete="UploadComplete" OnClientUploadStarted="StartUpload"
                    Width="300px" />

            <div class="gallery">
                <asp:DataList ID="dlV" runat="server" RepeatColumns="4" RepeatDirection="Horizontal"

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

modify the script like this
document.getElementById('lblStatus').innerText = 'Uploading Completed.';
var datGrid = document.getElementById('<%=dlV.ClientID %>');

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HainKurtSr. System AnalystCommented:

R8VIAuthor Commented:
HI masterpass,

I now get error
A run time error has occured
Error: sys.invalidoperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method

Please Help


How do you bind data to the Datalist ? Is that a button which will populate the datalist to be databinded ?
R8VIAuthor Commented:
soory my fault not realeted to what ypu helped me with
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.