0
votes

I have a div(runat=server) that contain repeater,this repeater is getting is value from datatable

when the datatable is empty I do this line of code in asp .net function

divname.innerHTML="<img src="...>"

on this page there is also a asp:button that fill the datatable with values. when pressing the button ,the above line isn't excute,the page offcourse is doing postback, but the div content isn't changing back to his original value(the repeater).

What do I have to do in the postback in order to force the div to get his original values?

This is code example:

     sub page_load(..
if ispostback=false then
         run_div()
end if
        end sub

        sub run_div()

    if datatable.Rows.Count=0 then
    divname.innerHTML="<img src="...>"


    end if
    end sub


sub filldata(....

fill datatable
 repeater.datasource=...
    repeater.databind
run_div()

end sub



    html look like this

    <div runat=servver id=divname><asp:repeater>.....
    <asp:button onclick="filldata">

Thanks for any help

1

1 Answers

0
votes

Assuming the variable named datatable is a System.Data.DataTable, remember that it only exists and had data in the context of a sibgle run of the page lifecycle. if the page is re-generated (whether it's via a postback or an initial load of the page) the DataTable is empty until it's loaded.

However, the Repeater object is stored in teh ViewState. IT will have values on a postback if there were rows on the previous load.

Instead of looking at the number of rows in the table, you should be looking at the Repteater.Items.Count.

If repeater.Items.Count = 0 Then
   divname.innerHTML="<img src="...>"    
Else
   ...
End If