ASP.NET - How to autorefresh a gridview  ASP.NET - How to autorefresh a gridview

Asked By Bikash Samal
15-Nov-10 03:19 AM
In a ASP.NET page I want to refresh only a gridview in time interval of 30 secs instead of autorefresh the whole page.
How to do this....??? means whats the codeto write??

plz help me out.......

advance thanks
  Jatin Prajapati replied to Bikash Samal
15-Nov-10 03:25 AM
For this you can use the timer of AJAX and put that grid in updated panel. And then on the timer's time elapsed event updated your data grid.
  Shailendrasinh Parmar replied to Bikash Samal
15-Nov-10 03:26 AM
You can refresh the data of grid at certain time interval using Ajax update panel.

Please check the following article for more details about the logic and code.

http://asp-net-csharp-vb.blogspot.com/2009/06/auto-refresh-data-on-page-using-ajax.html

Hope this helps.
  Bikash Samal replied to Jatin Prajapati
15-Nov-10 03:28 AM
Could u plz send me the total code to help me out...????


  Shailendrasinh Parmar replied to Bikash Samal
15-Nov-10 03:34 AM
Here is the code for you from the same article

Public Sub BindData()

 

  con = New SqlConnection("Initial Catalog=Northwind; Data Source=localhost; Uid=sa; pwd=;")

  cmd.CommandText = "select * from Employees "

  cmd.Connection = con

  con.Open()

  da = New SqlDataAdapter(cmd)

  da.Fill(ds)

  cmd.ExecuteNonQuery()

  GridData.DataSource = ds

  GridData.DataBind()

End Sub
 

You can check your current time on page load. Write this code:

     MyLabel.Text = System.DateTime.Now.ToString()
    BindData()

and grid refresh time is:

Protected Sub Timer1_Tick(ByVal sender As ObjectByVal e As EventArgs)

  Label1.Text = "Grid Refreshed at: " + DateTime.Now.ToLongTimeString()

End Sub

Here is HTML desing code:

<form id="form1" runat="server">

   <asp:Label ID="Label2" runat="server" Text="This is Time, When The Full Page Load :" Font-Bold="true"></asp:Label>&nbsp;

   <asp:Label ID="MyLabel" runat="server"></asp:Label><br /><br />     

  

  <asp:ScriptManager ID="ScriptManager1" runat="server" />

    <div>

      <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="30000">

      </asp:Timer>

    </div>

    <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">

      <Triggers>

        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />

      </Triggers>

      <ContentTemplate>

        <asp:Label ID="Label3" runat="server" Text="This is The Time when Only Data Grid will Referesh :" Font-Bold="true"></asp:Label>&nbsp;

        <asp:Label ID="Label1" runat="server" Text="Grid not refreshed yet."></asp:Label><br />

        <asp:Label ID="Label4" runat="server" Text="(Grid Will Referesh after Every 30 Sec)" Font-Bold="true"></asp:Label>&nbsp;

        <br /><br />

        <asp:DataGrid ID=GridData runat="server" Width="100%" GridLines="Both" HeaderStyle-BackColor="#999999" AutoGenerateColumns="false">

          <Columns>

            <asp:BoundColumn DataField="EmployeeID" HeaderText="Employee ID"></asp:BoundColumn>

            <asp:BoundColumn DataField="FirstName" HeaderText="First Name"></asp:BoundColumn>

             <asp:BoundColumn DataField="LastName" HeaderText="Last Name"></asp:BoundColumn>

            <asp:BoundColumn DataField="City" HeaderText="City"></asp:BoundColumn>

          </Columns>

        </asp:DataGrid>

           

      </ContentTemplate>

    </asp:UpdatePanel>   

   

  </form> 

  Bikash Samal replied to Shailendrasinh Parmar
15-Nov-10 03:42 AM
Does this code apply to child page too???
And one thing more, I've a connection string and I don't think that I should try this connection string....
Is there any connection to refresh with the connection string???
  Shailendrasinh Parmar replied to Bikash Samal
15-Nov-10 03:48 AM
Yes, this code will work in all pages.

For connection, definitely, you need the connection to connect to the sql server database to retrieve the data, otherwise how can you get newly entered data without a connection to the database?
  undhad ashwin replied to Bikash Samal
15-Nov-10 03:56 AM
hi try below solution

i am explaining how we can automatic refresh data on an ASP.NET page after a certain interval using AJAX UpdatePanel and other controls. I am using some Ajax controls and using SQL server database and Data Grid control. Database name is north wind. In this application my interval time for refresh data is 60 second. We can change your time by times interval property.

//This code for display data in the datagrid:

public void DisplayData()

{

System.Data.SqlClient.SqlConnection = new System.Data.SqlClient.SqlConnection("Initial Catalog=Northwind; Data Source=localhost; Uid=sa; pwd=;");

System.Data.SqlClient.SqlDataAdapter ds = new System.Data.SqlClient.SqlDataAdapter("select * from Employees", cn);

DataSet ds = new DataSet();

da.Fill(ds);

myGrid.DataSource = ds;

myGrid.DataBind();

}

protected void Page_Load(object sender, EventArgs e)

{

//You can check your current time on page load. Write this code:

lblTime.Text = System.DateTime.Now.ToString();

DisplayData();

}

protected void Timer1_Tick(object sender, EventArgs e)

{

//Datagrid refresh time

lbldgTime.Text = "Refresh at:" + System.DateTime.Now.ToString();

DisplayData();

}

//This is HTML Code:

<form id="form1" runat="server">

<asp:Label ID="Label2" runat="server" Text="This is Time, When The Full Page Load :" Font-Bold="true"></asp:Label>&nbsp;

<asp:Label ID="lblTime" runat="server"></asp:Label><br /><br />

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<div>

<asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="30000">

</asp:Timer>

</div>

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">

<Triggers>

<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />

</Triggers>

<ContentTemplate>

<asp:Label ID="Label3" runat="server" Text="This is The Time when Only Data Grid will Referesh :" Font-Bold="true"></asp:Label>&nbsp;

<asp:Label ID="lbldgTime" runat="server" Text="Grid not refreshed yet."></asp:Label><br />

<asp:Label ID="Label4" runat="server" Text="(Grid Will Referesh after Every 60 Sec)" Font-Bold="True"></asp:Label>&nbsp;

<br /><br />

<asp:DataGrid ID=myGrid runat="server" Width="100%" GridLines="Both" HeaderStyle-BackColor="#999999" AutoGenerateColumns="false">

<Columns>

<asp:BoundColumn DataField="EmployeeID" HeaderText="Employee ID"></asp:BoundColumn>

<asp:BoundColumn DataField="FirstName" HeaderText="First Name"></asp:BoundColumn>

<asp:BoundColumn DataField="LastName" HeaderText="Last Name"></asp:BoundColumn>

<asp:BoundColumn DataField="City" HeaderText="City"></asp:BoundColumn>

</Columns>

<HeaderStyle BackColor="#999999" />

</asp:DataGrid>

</ContentTemplate>

</asp:UpdatePanel>

</form>

I hope this code example will be useful

if any query then reply


  Manoranjan Sahoo replied to Bikash Samal
15-Nov-10 04:00 AM
check below code :

in aspx page make the code like below :

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Untitled Page</title>
  <script type="text/javascript">
   
    function pageLoad() {
    }
   
  </script>
</head>
<body>
  <form id="form1" runat="server">
  <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:Timer ID="Timer1" runat="server" Interval="1000">
    </asp:Timer>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers >
    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
    </Triggers>
    <ContentTemplate >
      <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
  <Columns >
     
     <asp:TemplateField  HeaderText="<font color='red'>Name</font>">
      <ItemTemplate >
        <asp:Label ID="Label2" runat="server" Text='<%# Eval("column1") %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>
     <asp:TemplateField  HeaderText="<font color='red'>Link Name</font>">
      <ItemTemplate >
        <asp:Label ID="Label2" runat="server" Text='<%# Eval("column2") %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>
         
  </Columns>
  </asp:GridView>
    </ContentTemplate>
    </asp:UpdatePanel>
  </div>
  </form>
</body>
</html>

Now in page.aspx.cs make code like below :
SqlConnection cn;
protected void Page_Load(object sender, EventArgs e)
{
  cn = new SqlConnection(" put your connection string");
 
  bindData();
 
}
void bindData()
{
  string strsql = "Select column1,column2 from Table1 order by column1";
  SqlDataAdapter dacontent = new SqlDataAdapter(strsql, cn);
  DataSet dscontent = new DataSet();
  string content = "";
  dacontent.Fill(dscontent, "TableData");
  GridView1.DataSource = dscontent.Tables[0];
  GridView1.DataBind();
  Label1.Text = "Grid Refreshed at :"+ DateTime.Now .ToString ();
}
  Bikash Samal replied to Shailendrasinh Parmar
15-Nov-10 04:36 AM
Thanks its working...
but now a new issue came out.....
The data inside gridview is not refresh.......
What to do now???
plz help me out soon....

Advance thanks...........
  Shailendrasinh Parmar replied to Bikash Samal
15-Nov-10 05:03 AM
I think your gridview is also in updatepanel, so at the binding time, you need to refresh the updatepanel also.

like this , UpdatePanel1.Update();

Hope this helps.
  Bikash Samal replied to Shailendrasinh Parmar
15-Nov-10 05:43 AM
Thanks for reply....
but still its not working....
if any other way, then specify...........
actually modified data show only when i refresh the whole page but not in the gridview refresh....
  Shailendrasinh Parmar replied to Bikash Samal
15-Nov-10 05:47 AM
Hi,

If you are using the Timer and its click event, then write the code for updating the update panel on Timer1_Click event.

Try this.
  Bikash Samal replied to Shailendrasinh Parmar
15-Nov-10 05:55 AM
Ya, I am using timer control....
But itz not working in Timer Tick event also....
What to do next....
  Shailendrasinh Parmar replied to Bikash Samal
15-Nov-10 06:02 AM
Confused dear.. can you give me your code as zip or something? I will test and tell you later!!
  Bikash Samal replied to Shailendrasinh Parmar
15-Nov-10 06:16 AM
ok....This is the Buddy.aspx page............
-----------------------------------------------------------------
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"  CodeFile="Buddy.aspx.cs" Inherits="Buddy" Title="MicroBTS--[Your Staff Buddies]" ValidateRequest="false"  EnableEventValidation="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script language="javascript" type="text/javascript" src="../Css/dhtmlwindow1.js">

</script>

<script language="javascript" type="text/javascript">
        function invclose()
        {

           dhtmlwindow.close('dwnloadbackup');  // Div with resize
            return false;
         }   
        function openinvitediv()
         {          
               
                  document.location.href="addbuddy.aspx"
                   return false; 
         }     
            
         function opendiv()
         {
           
                dhtmlwindow.open('divbox', 'div','dwnloadbackup', 'MESSAGE', 'width=578px,height=370px,left=210px,top=328px,resize=1,scrolling=0,center=1');
               document.getElementById('<%=this.txtMessage.ClientID %>').focus();
                return false;        
                
         }    
        
     function SelectAll(id)
        {
            //get reference of GridView control
            var grid = document.getElementById('<%= this.gvCheckboxes.ClientID %>');
            //variable to contain the cell of the grid
            var cell;
            
            if (grid.rows.length > 0)
            {
                //loop starts from 1. rows[0] points to the header.
                for (i=1; i<grid.rows.length; i++)
                {
                    //get the reference of first column
                    cell = grid.rows[i].cells[0];
                    
                    //loop according to the number of childNodes in the cell
                    for (j=0; j<cell.childNodes.length; j++)
                    {           
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type =="checkbox")
                        {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                            cell.childNodes[j].checked = document.getElementById(id).checked;
                        }
                    }
                }
            }
        }
        
     function displaydiv()
     {       

         document.getElementById("dwnloadbackup").style.display="";         
         return false;
     }     
     
     function chekboxalert_onclick() 
     {      
          var TargetBaseControl = document.getElementById('<%= this.gvCheckboxes.ClientID %>');
          var isAnyChecked=false;
          var myCheckBoxList=TargetBaseControl.getElementsByTagName("input");      
          var servercheck = document.getElementById('<%= this.Chekbxmoblno.ClientID %>');
         
          if(!(servercheck.checked))
          {
              for(var i=0;i<myCheckBoxList.length ;i++)
               {
                 
                   if(myCheckBoxList[i].id.indexOf("CheckBox") >= 0)
                       {
                            
                            if(myCheckBoxList[i].checked==true)
                                {
                                   
                                    isAnyChecked=true
                                }
                        }
                }
           }
           else
           {
             isAnyChecked=true 
           } 
            
            if(isAnyChecked == true)
            {
                var text=document.getElementById('<%=this.txtMessage.ClientID %>').value     
                   
                if( text!="")
                    {
                        if(servercheck.checked==true)
                        {
                        var mo=document.getElementById('<%=this.txtmoblno.ClientID %>').value
                            if(mo.length<10)
                            {
                                alert("Please Enter 10 Digit Mobile No. eg- 9XXXXXXXXX.")
                                return false;
                            }
                            else
                            {
                            
                            }
                        }
                        else
                        {
                        
                        }
                    } 
                else
                    {
                        alert("Please Enter message");
                        return false;
                    }
               
            }
           else
            {
               
                
                    alert("Please select Buddy");
               
                 return false;
            }
            
    }     
     
   
 function ascii_value (c)
{
// restrict input to a single character
c = c . charAt (0);

// loop through all possible ASCII values
var i;
for (i = 0; i < 256; ++ i)
{
// convert i into a 2-digit hex string
var h = i . toString (16);
if (h . length == 1)
h = "0" + h;

// insert a % character into the string
h = "%" + h;

// determine the character represented by the escape code
h = unescape (h);

// if the characters match, we've found the ASCII value
if (h == c)
break;
}
return i;
}


    function textCounter(field, countfield, maxlimit) 
    {
            var MaxLength = 1000;
            var Label2 = document.getElementById(countfield);
            
            if (field.value.length > maxlimit)
                field.value = field.value.substring(0,maxlimit);
                
            Label2.innerText = '('+(maxlimit - field.value.length)+' Characters remaining)';
    }
    
  function IncreaseHeight()
  {
        var  tb = document.getElementById('<%=txtMessage.ClientID %>');
        var l = 90; 
        var currentL = tb.value.length;
        var row = currentL / l;
        tb.rows = row+4;
  }     
     
 
    function isNumberKey(evt)
    {
         var charCode = (evt.which) ? evt.which : event.keyCode
         
         if (charCode > 31 && (charCode < 48 || charCode > 57))
         {
            alert("Please Enter Valid Character in Mobile Number")
            return false; 
         }
         
         return true;
     }  
     
    function isUserNameKey(evt)
    {
         var charCode = (evt.which) ? evt.which : event.keyCode
    
         if (!((charCode >= 45 && charCode <= 57) || (charCode >= 97 && charCode <= 122)|| (charCode >= 64 && charCode <= 90) ||(charCode==95)) )
         {
            alert("Please Enter Valid Character")
            return false; 
         }
         
         return true;
     } 
     
     function isNameKey(evt)
    {
         var charCode = (evt.which) ? evt.which : event.keyCode
         
          if (!((charCode==46)||(charCode >= 97 && charCode <= 122)|| (charCode >= 65 && charCode <= 90) ||(charCode==32)||(charCode==39)) )
         {
            alert("Please Enter Valid Character")
            return false; 
         }
         
         return true;
     }  
                     
     
    function enableExterNameTextBox(chk)
    {
        if(chk.checked)
            {
                document.getElementById('<%=this.txtmoblno.ClientID %>').disabled= false;
                document.getElementById('<%=this.txtmoblno.ClientID %>').style.backgroundColor = 'white';
            }
        else
            {
                document.getElementById('<%=this.txtmoblno.ClientID %>').disabled= true;
                document.getElementById('<%=this.txtmoblno.ClientID %>').value = " ";
                document.getElementById('<%=this.txtmoblno.ClientID %>').style.backgroundColor = 'silver';
            }
            
       
    }     
     function winopengmt(handset)  // Open Google Maps Page on Grid Compass Image
     {
         window.open('http://www.microfms.net/tracking/buddyReplay_Selection.asp?vehicle_id=' + handset,'','height=600,width=820,menubar=yes,location=no,resizable=yes,scrollbars=no,status=no,top=0,left=100');
        return false;
     }          
     function winopen(handset,strname,strdate,Enddate,uphoto,uid,model) // Open Google Maps Page on Grid Compass Image
     {
         //alert(model);
         window.open('finaltrace.aspx?vchhandset=' + handset + '&name=' + strname + '&startdate=' + strdate + '&enddate=' + Enddate + '&userphoto=' + uphoto + '&id=' + uid + '&modelno=' + model, '', 'height=600,width=768,menubar=no,location=no,resizable=yes,scrollbars=no,status=no,top=0,left=0');
        return false;
     }        
     function fnEmergencyMap(id)  // Open Emergency Map
     {
        window.open('emergencymap.aspx?user='+id,'','height=600,width=820,menubar=yes,location=no,resizable=yes,scrollbars=no,status=no,top=0,left=100');
        return false;
     }   
        
     function winopengoogle()       // Opens Google Maps for View ALL with compass.png
     {
        window.open('handset.aspx','','height=400,width=600,menubar=No,location=No,resizable=yes,scrollbars=yes,status=No,top=110,left=180');
        return false;
     }

     function winopenmt()           // Opens ASPMAPS Maps for View ALL with mt.png
     {
        window.open('handset1.aspx','','height=400,width=600,menubar=No,location=No,resizable=yes,scrollbars=yes,status=No,top=110,left=180');
        return false;
     }        

     function winopenmulti()        // Opens MicroBTS Single Google Maps for View ALL
     {
        window.open('tabMultiple.aspx','','menubar=No,location=No,resizable=yes,scrollbars=yes,status=yes,top=110,left=180');
        return false;
     }
     function winopenlogs(user,handset,name)
    {

        window.open('Gpslocationlogs1.aspx?user='+user+'&handset1='+handset+'&name='+name,'','height=580,width=620,menubar=No,location=No,resizable=no,scrollbars=yes,status=No,top=110,left=180');
        return false;

    } 
    
    function fence()  // Open GeoFencePage 
     {
        
        window.open('setgeofence.aspx','','height=600,width=768,menubar=yes,location=yes,resizable=yes,scrollbars=no,status=yes,top=0,left=0');
        return false;
     }    
    
   

  function openzicom(varname,varlicensekey,varstartdate,varenddate)  // Open Google Maps Page on Grid mt Image for zicom
     {
    
     window.open('http://www.microfms.net/ptrack/bts/BuddyTrack_Trace.aspx?Buddy Name='+varname+'&licenskey='+ varlicensekey+'&startdate='+varstartdate+'&enddate='+varenddate+'','_child','height=450,width=680,menubar=no,location=yes,resizable=yes,scrollbars=yes,status=no,top=0,left=0');
     
        return false;
     } 
     
     function yahoomaps()
     {
     window.open('Yahoomaps.aspx','','menubar=No,location=No,resizable=yes,scrollbars=yes,status=No,top=110,left=180');
     return false;
     } 
   
    
     
    
      String.prototype.trim = function() { a = this.replace(/^\s+/, ''); return a.replace(/\s+$/, ''); };   
 
  
     
  function goClick(buttonName,e)
    {
//the purpose of this function is to allow the enter key to 

//point to the correct button to click.

        var key;

         if(window.event)
              key = window.event.keyCode;     //IE

         else
              key = e.which;     //firefox

    
        if (key == 13)
        {
            //Get the button the user wants to have clicked

            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it

                btn.click();
                event.keyCode = 0
            }
        }
        
   }
  
  function winopenmlive(handset,strname,strdate,Enddate,uphoto,uid,model)
  {
      window.open('Microsoftmaps.aspx?vchhandset=' + handset + '&name=' + strname + '&startdate=' + strdate + '&enddate=' + Enddate + '&userphoto=' + uphoto + '&id=' + uid + '&modelno=' + model, '', 'height=600,width=820,menubar=yes,location=no,resizable=yes,scrollbars=no,status=yes,top=0,left=100');
    
    return false;
  }
  
  function winopenyahoo(handset,strname,strdate,Enddate,uphoto,uid,model)
  {
      window.open('finaltraceyahoomap.aspx?vchhandset=' + handset + '&name=' + strname + '&startdate=' + strdate + '&enddate=' + Enddate + '&userphoto=' + uphoto + '&id=' + uid + '&modelno=' + model, '', 'height=600,width=820,menubar=no,location=no,resizable=yes,scrollbars=no,status=no,top=0,left=100');
    
    return false;
  }
  
</script>  
       
    <table style="width: 778px;background-color: #d7f0f4;" cellpadding="0" cellspacing="0">    
        <tr>
            <td  align="left">
        
<table style="Z-INDEX: 100; WIDTH: 600px;"><tbody><TR><TD style="WIDTH: 413px; height: 35px;" align="left"><P style="MARGIN-LEFT: 10px"><FONT face="Verdana" size=3>
    
    <table cellpadding="0" cellspacing="0" style="width: 774px">
        <tr>
            <td style="width: 38px; height: 28px">
                <asp:Image id="Image2" runat="server" ImageUrl="../Images/buddy_28.gif"></asp:Image></td>
            <td style="width: 230px; height: 28px" valign="bottom">
                <asp:Label id="Label4" runat="server" Font-Size="12pt" Font-Names="Verdana" Text="Your Staff Buddies" Font-Bold="True"></asp:Label></td>
            <td style="width: 10px; height: 28px">
            </td>
            <td style="width: 25px; height: 28px">
            </td>
            <td align="right" style="height: 28px">
    <asp:Label ID="lblCnt" runat="server" Font-Names="Verdana" Font-Bold="True" Font-Size="8pt" ForeColor="DarkSlateGray"></asp:Label>
                <asp:Label ID="lblcnt1" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="12pt" ForeColor="Blue"></asp:Label></td>
        </tr>
    </table>
</FONT></P></TD></TR><TR><TD style="WIDTH: 413px" valign=top align=right><table style="WIDTH: 570px" cellSpacing="0" cellPadding="0" align="right"><TBODY><TR><TD align=center style="width: 34px">&nbsp; </TD><TD style="WIDTH: 551px" vAlign=top align=left><TABLE style="WIDTH: 752px"><TBODY><TR><TD style="WIDTH: 572px; HEIGHT: 1px" align=center>
    <asp:Panel  runat="server" ID="panviewall" >
    <table style="WIDTH: 778px; height: 19px;" cellpadding="0" cellspacing="0" id="tblviewall"><TBODY><TR><TD style="width: 98px; height: 25px;" align="left">
    <asp:LinkButton ID="lnkbtnViewAll" runat="server" Text="View All" Width="64px"  Font-Bold="True" Font-Names="Verdana" Font-Size="10pt" ForeColor="Blue"  Font-Underline="False" ToolTip="View All"></asp:LinkButton><asp:Label
        ID="Label14" runat="server" ForeColor="Blue" Text="--"></asp:Label></TD>
    <td align="right" style="width: 31px; height: 25px;">
        <asp:ImageButton ID="ImageButton4" ImageUrl="../Images/mt.png"  runat="server" Width="23px" ImageAlign="AbsBottom" OnClientClick="return winopenmt()" ToolTip="MTIL Map" />&nbsp;</td>
    <td align="left" style="width: 8px; height: 25px;">
        <asp:Label ID="Label9" runat="server" Font-Bold="True" Font-Size="14pt" Text="|"
            Width="1px"></asp:Label></td>
    <td align="left" style="width: 66px; height: 25px;" valign="bottom">
        &nbsp;<asp:ImageButton ID="ImageButton3" ImageUrl="../Images/compass1.png" runat="server" Height="16px" OnClientClick="return winopengoogle()" ToolTip="Google Map" />
        &nbsp;
    </td>
        <td align="left" style="width: 464px; height: 25px">
            <asp:Label ID="Label15" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="10pt"
                Text="Search Buddy : "></asp:Label>&nbsp<asp:TextBox ID="txtSearch" runat="server" TabIndex="3"
                    Width="134px"></asp:TextBox> &nbsp <asp:ImageButton ID="imgbtnSearch" runat="server" ImageAlign="AbsMiddle"
                        ImageUrl="../Images/searchnew.JPG" OnClick="imgbtnSearch_Click" /> &nbsp <asp:Button ID="btnAll"
                            runat="server" Font-Names="Verdana" Font-Size="10pt" OnClick="btnAll_Click" Style="border-right: black 1px solid;
                            border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid"
                            Text="All" Width="37px" />&nbsp;
        </td>
    <TD style="width: 300px; height: 25px;" align="right" valign="middle">
        <asp:Label ID="Label1" runat="server" Text="Show Buddies&nbsp;:&nbsp;" Font-Names="Verdana" Font-Size="10pt"></asp:Label>&nbsp;&nbsp;
        <asp:DropDownList ID="ddlstatus" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlstatus_SelectedIndexChanged">
            <asp:ListItem Selected="True">Active</asp:ListItem>
            <asp:ListItem>Inactive</asp:ListItem>
            <asp:ListItem>All</asp:ListItem>
        </asp:DropDownList>&nbsp;
        <asp:ImageButton ID="ImageButton6" runat="server" OnClick="ImageButton6_Click" ToolTip="Refresh" ImageUrl="../Images/images[13].jpg" /></TD></TR>
        <tr>
            <td align="left" style="width: 98px; height: 9px">
            </td>
            <td align="right" style="width: 31px; height: 9px">
            </td>
            <td align="left" style="width: 8px; height: 9px">
            </td>
            <td align="left" style="width: 66px; height: 9px" valign="bottom">
            </td>
            <td align="left" style="width: 464px; height: 9px">
            </td>
            <td align="left" style="width: 300px; height: 9px" valign="middle">
            </td>
        </tr>
    </TBODY></TABLE></asp:Panel>
    &nbsp;

//timer control to refresh gridview in every 30 secs
    <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" 
Interval="30000" Enabled="True" OnDataBinding="Timer1_Tick">  
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
    <Triggers>  
        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />  
    </Triggers>  
    <ContentTemplate>
<asp:Label id="Label112" runat="server" Text="" __designer:wfdid="w2"></asp:Label> <asp:GridView id="gvCheckboxes" runat="server" GridLines="Horizontal" DataKeyNames="intuserid" AutoGenerateColumns="False" OnRowDataBound="gvCheckboxes_RowDataBound" Height="96px" Width="780px" __designer:wfdid="w3" AllowSorting="true" AllowPaging="true">
<EmptyDataRowStyle ForeColor="Maroon" Font-Size="10pt" Font-Names="verdana"></EmptyDataRowStyle>
<Columns>
<asp:TemplateField><HeaderTemplate>
<ItemStyle Width="90px" BorderColor="#404040" HorizontalAlign="Left"></ItemStyle>

<HeaderStyle BackColor="#006699" ForeColor="White" HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate></ItemTemplate>       
    <asp:CheckBox ID="chkBxHeader" runat="server" onclick="javascript:HeaderClick(this);" />
</HeaderTemplate>

<ItemStyle BackColor="LemonChiffon" Width="1px" BorderColor="Black" HorizontalAlign="Center"></ItemStyle>

<HeaderStyle BorderStyle="None" Width="1px" BorderColor="#FF8000" HorizontalAlign="Center"></HeaderStyle>
<ItemTemplate>
<asp:CheckBox id="CheckBox" runat="server"></asp:CheckBox> 
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Buddies">
<ItemStyle BackColor="LemonChiffon" Width="240px" BorderColor="Black" HorizontalAlign="Left" Font-Size="9pt" Font-Names="Verdana"></ItemStyle>

<HeaderStyle BorderStyle="None" Width="100px" BorderColor="#FF8000" HorizontalAlign="Center" Font-Size="10pt" Font-Names="Verdana"></HeaderStyle>
    <ItemTemplate>
        <asp:Image ID="imgbuddy" runat="server" ImageUrl='<%#Eval("imagepath") %>' ImageAlign="AbsMiddle">
        </asp:Image>
        <asp:HyperLink ID="HyperLink5" runat="server" ForeColor="Black" Font-Bold="False"
            Font-Underline="False" Visible="False">[HyperLink5]</asp:HyperLink><asp:Label ID="lblModel"
                runat="server" Text="" Visible="False"></asp:Label>
        <table>
            <tr>
                <td style="width: 33px">
                    <asp:Button ID="Button2" runat="server" Text="SMS" OnClick="Button2_Click" /></td>
            </tr>
        </table>
    </ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Updated Location">
<ItemStyle Width="530px" BorderColor="White" HorizontalAlign="Left" Font-Size="9pt" Font-Names="Verdana"></ItemStyle>

<HeaderStyle BorderStyle="None" Width="780px" BorderColor="#FF8000" HorizontalAlign="Center" Font-Size="10pt" Font-Names="Verdana"></HeaderStyle>
<ItemTemplate>
<TABLE><TBODY><TR><TD align=left><asp:Label id="lbllocationc" runat="server" ForeColor="Black" Font-Size="10pt" Font-Names="Verdana" Font-Bold="False" Visible="False"></asp:Label><asp:Label id="lbl" runat="server" ForeColor="Brown" Font-Size="10pt" Font-Names="Verdana" Text="(" Font-Bold="True" Visible="False"></asp:Label><asp:Label id="lbldtlocation3" runat="server" ForeColor="Blue" Font-Size="10pt" Font-Names="Verdana" Font-Bold="True" Visible="False"></asp:Label><asp:Label id="lbldtlocation4" runat="server" Font-Size="10pt" Font-Names="Verdana" Text="Label" Font-Bold="True" Visible="False"></asp:Label><asp:Label id="lbl1" runat="server" ForeColor="Brown" Font-Size="10pt" Font-Names="Verdana" Text=")" Font-Bold="True" Visible="False"></asp:Label> </TD></TR><TR><TD align=left><asp:Label id="lbllast" runat="server" ForeColor="Brown" Text="Label" Font-Bold="True" Visible="False" Font-Size="10pt"></asp:Label>&nbsp;
    <asp:Label id="lbllocation" runat="server" ForeColor="Black" Font-Size="10pt" Font-Names="Verdana" Font-Bold="True"></asp:Label> <asp:Label id="Label11" runat="server" ForeColor="Brown" Font-Size="10pt" Font-Names="Verdana" Text="(" Font-Bold="True"></asp:Label><asp:Label id="lbldtlocation1" runat="server" ForeColor="Blue" Font-Size="10pt" Font-Names="Verdana" Font-Bold="True"></asp:Label><asp:Label id="lbldtlocation2" runat="server" Font-Size="10pt" Font-Names="Verdana" Font-Bold="True"></asp:Label><asp:Label id="Label7" runat="server" ForeColor="Brown" Font-Size="8pt" Font-Names="Verdana" Text=")" Font-Bold="True"></asp:Label><asp:Label id="lblnotavlable" runat="server" Font-Size="12px" Font-Names="Verdana" Text="--Not Available--" Visible="False"></asp:Label> <asp:ImageButton id="imgbtnintimation" runat="server" ImageUrl="../Images/message.png" ToolTip="Set Intimation" Visible="False"></asp:ImageButton>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:HiddenField id="hdnfavorite" runat="server"></asp:HiddenField> </TD></TR></TBODY></TABLE>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Speed">
<ItemStyle BackColor="#FFFFCC" Width="30px" HorizontalAlign="Center" Font-Size="10pt" Font-Names="Verdana" Font-Bold="False"></ItemStyle>

<HeaderStyle Font-Size="10pt" Font-Names="Verdana"></HeaderStyle>
<ItemTemplate>
        <table style="width:126px">
        <tr>
        <td style="width:60px" align="center"><asp:Label ID="Label2" runat="server"  Font-Bold="True" Font-Size="10pt" ToolTip="Speed"></asp:Label></td>
        </tr>       
        <tr>
        <td style="width:60px"><asp:Label ID="lblstate" runat="server" Font-Bold="True" Font-Size="10pt" Visible="False" ></asp:Label></td>
        </tr>
            <tr>
                <td style="width: 60px;" align="center" valign="top">
                    <asp:Label ID="lblaccelaration" runat="server" Font-Bold="True" 
                        Font-Size="10pt" ToolTip="Acceleration" ForeColor="Maroon" Width="131px"></asp:Label>
                    </td>
            </tr>
        
        </table>
            
        
</ItemTemplate>
    <ControlStyle Width="90px" />
</asp:TemplateField>

<asp:TemplateField HeaderText="Maps">
        <ItemStyle Width="150px" BorderColor="White" HorizontalAlign="Center" Font-Size="9pt" Font-Names="Verdana"></ItemStyle>

        <HeaderStyle BorderStyle="None" Width="100px" BorderColor="#FF8000" HorizontalAlign="Center" Font-Size="10pt" Font-Names="Verdana"></HeaderStyle>
        <ItemTemplate>
        
       
        
            <table style="width: 32px">
                <tbody>
                    <tr>
                        <td style="width: 30px">
                            <asp:ImageButton ID="Replayimage" runat="server" ImageUrl="../Images/mt.png" ImageAlign="AbsMiddle"
                                Width="23px" Height="16px" ToolTip="Mtil map"></asp:ImageButton></td>
                        <td style="width: 2px">
                            <asp:Label ID="lblpipe3" runat="server" Font-Size="10pt" Text="|" Width="1px" Height="10px"
                                Font-Bold="True"></asp:Label></td>
                        <td style="width: 30px">
                            <asp:ImageButton ID="Googleimage" runat="server" ImageUrl="../Images/compass1.png"
                                ImageAlign="AbsMiddle" Height="16px" ToolTip="Google Map"></asp:ImageButton></td>
                        <td style="width: 30px">
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td style="width: 30px">
                            <asp:ImageButton ID="ImageButton5" runat="server" ImageUrl="../Images/windowsmaps.jpeg"
                                ImageAlign="AbsMiddle" Height="16px" ToolTip="Microsoft Live Map"></asp:ImageButton></td>
                        <td style="width: 2px">
                            <asp:Label ID="Label16" runat="server" Font-Size="10pt" Text="|" Width="1px" Height="10px"
                                Font-Bold="True"></asp:Label></td>
                        <td style="width: 30px">
                            <asp:ImageButton ID="ImageButton7" runat="server" ImageUrl="../Images/yahoomap.jpeg"
                                ImageAlign="AbsMiddle" Height="16px" ToolTip="Yahoo Map"></asp:ImageButton></td>
                        <td style="width: 30px">
                        </td>
                    </tr>
                </tbody>
            </table>
        </ItemTemplate>
    <ControlStyle Width="18px" />
</asp:TemplateField>

<asp:TemplateField HeaderText="Status">
<ItemStyle BackColor="#FFFFCC" BorderColor="White" HorizontalAlign="Center" Font-Size="9pt" Font-Names="Verdana"></ItemStyle>

<HeaderStyle BorderStyle="None" BorderColor="#FF8000" HorizontalAlign="Center" Font-Size="10pt" Font-Names="Verdana"></HeaderStyle>
<ItemTemplate>
<TABLE style="WIDTH: 82px" cellSpacing=0 cellPadding=0 align=left>
<TBODY><TR><TD style="WIDTH: 28px; HEIGHT: 32px">
<asp:Image id="imgonoff" runat="server" ImageUrl='<%#Eval("trasit")%>' ImageAlign="AbsMiddle" Height="12px"></asp:Image></TD>
<TD style="WIDTH: 4px; HEIGHT: 32px" ><asp:Label id="lblpipe9" runat="server" Font-Size="10pt" Text="|" Height="10px" Font-Bold="True"></asp:Label> </TD>
<TD style="WIDTH: 40px; HEIGHT: 32px" ><asp:Image id="imgbattery" runat="server" ImageUrl='<%#Eval("batterylevel")%>' ImageAlign="AbsMiddle"></asp:Image></TD>
<TD style="WIDTH: 10px; HEIGHT: 32px" ><asp:Label id="lblbatteryper" runat="server" Font-Size="10pt">lblper</asp:Label></TD>
</TR>
    <tr>
        <td colspan="4" style="height: 32px" align="center">
            <asp:ImageButton ID="btnStatus" runat="server" ImageUrl="../Images/get_status.jpg"
                OnClick="btnStatus_Click" /></td>
    </tr>
</TBODY></TABLE>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Emergency">
<ItemStyle  BorderColor="White" HorizontalAlign="Center" Font-Size="9pt" Font-Names="Verdana"></ItemStyle>

<HeaderStyle BorderStyle="None" BorderColor="#FF8000" HorizontalAlign="Center" Font-Size="10pt" Font-Names="Verdana"></HeaderStyle>
<ItemTemplate>
<table>
<tr><td><asp:ImageButton id="imgEmergency" runat="server" ImageUrl="../Images/siren.gif" ImageAlign="AbsMiddle" Height="24px" ToolTip="Google Map"></asp:ImageButton></td> </tr>
<tr><td><asp:Label runat="server" id="lblemergencylastdate" Font-Size="10pt"></asp:Label></td> </tr>
</table>

</ItemTemplate>
</asp:TemplateField>
</Columns>

<RowStyle BackColor="Moccasin" VerticalAlign="Top"></RowStyle>
     <EmptyDataTemplate>
         <headerstyle backcolor="#006699" forecolor="White" horizontalalign="Left"></headerstyle>
         <table style="border-left: #18b0c5 1px ridge; border-right: #18b0c5 1px ridge; border-top: #18b0c5 1px ridge;
             border-bottom: #18b0c5 1px ridge; width: 100%;">
             <tr>
                 <th align="center" forecolor="White" style="background-color: #FF8000; border-bottom: White 1px ridge;
                     width: 190px; height: 35px;">
                     <asp:Label ID="Label3" runat="server" ForeColor="White" Text="Buddies"></asp:Label></th>
                 <th align="center" forecolor="White" style="background-color: #FF8000; border-bottom: White 1px ridge;
                     width: 109px; height: 35px;">
                     <asp:Label ID="Label81" runat="server" ForeColor="White" Text="Last Updated Location"
                         Width="176px"></asp:Label></th>
                 <th align="center" forecolor="White" style="width: 40px; border-bottom: white 1px ridge;
                     height: 35px; background-color: #ff8000">
                     <asp:Label ID="Label10" runat="server" ForeColor="White" Text="Replay"></asp:Label></th>
                 <th align="center" forecolor="White" style="width: 18px; border-bottom: white 1px ridge;
                     height: 35px; background-color: #ff8000">
                     <asp:Label ID="Label15" runat="server" ForeColor="White" Text="Buddy Status" Width="104px"></asp:Label></th>
             </tr>
             <tr>
                 <th align="center" forecolor="White" style="background-image: none; border-bottom: white 1px ridge;
                     height: 35px; background-color: navajowhite" colspan="4">
                     <asp:Label ID="Label161" runat="server" Font-Names="Verdana" Font-Size="9pt" ForeColor="Brown"
                         Text="No Active Buddies Currently Available" Width="309px"></asp:Label></th>
             </tr>
         </table>
     </EmptyDataTemplate>

<HeaderStyle BackColor="DarkOrange" Width="35px" ForeColor="White" Font-Bold="True"></HeaderStyle>

<AlternatingRowStyle BackColor="NavajoWhite"></AlternatingRowStyle>
</asp:GridView> 
</ContentTemplate>  
</asp:UpdatePanel>  
</TD></TR><TR><TD style="WIDTH: 572px;" align=right><TABLE  style="width: 750px" id="tbladd"><TBODY><TR><TD style="height: 12px">
   </TD>
    <TD style="WIDTH: 150px; HEIGHT: 12px;background-image: url(../Images/bgcolor.gif); BACKGROUND-COLOR: transparent; border-right: #000000 1px ridge; border-top: #000000 1px ridge; border-left: #000000 1px ridge; border-bottom: #000000 1px ridge;" align="left">
    <asp:ImageButton ID="ImageButton8" runat="server" ImageAlign="AbsBottom" ImageUrl="../Images/fence-s.png"
        OnClientClick="javascript:return fence();" /><asp:Button style="BACKGROUND-IMAGE: none; cursor:hand; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; BORDER-BOTTOM-STYLE: none" id="Button1" runat="server" Font-Size="13px" Font-Names="Verdana" Height="18px" Text="Add GeoFence" Width="110px" BorderStyle="None" OnClientClick="javascript:return fence();" CausesValidation="False"  ></asp:Button>
    </td>
  
    <TD style="WIDTH: 5px;">
    </td>
    
    <td style="width: 105px; height: 12px; background-image: url(../Images/bgcolor.gif);
        background-color: transparent; border-right: #000000 1px ridge; border-top: #000000 1px ridge;
        border-left: #000000 1px ridge; border-bottom: #000000 1px ridge;" align="left">
        &nbsp;
        <asp:ImageButton ID="ImageButton2" runat="server" ImageAlign="AbsBottom" ImageUrl="../Images/invite_buddy_01.png"
            OnClientClick="javascript:return openinvitediv()" /><asp:Button Style="background-image: none;
                cursor: hand; border-top-style: none; border-right-style: none; border-left-style: none;
                background-color: transparent; border-bottom-style: none" ID="btninvite" runat="server"
                Font-Size="13px" Font-Names="Verdana" Height="18px" Text="Add Buddy" Width="80px"
                BorderStyle="None" CausesValidation="False" OnClientClick="javascript:return openinvitediv();">
            </asp:Button></td>
    <TD style="; WIDTH: 4px; HEIGHT: 12px; BACKGROUND-COLOR: transparent"></TD>
    <asp:Panel runat="server" ID="panadd">
        <td style="background-image: url(../Images/bgcolor.gif); width: 160px; height: 18px;
            background-color: transparent; border-right: #000000 1px ridge; border-top: #000000 1px ridge;
            border-left: #000000 1px ridge; border-bottom: #000000 1px ridge;" align="left">
            &nbsp;<asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="AbsBottom" ImageUrl="../Images/compose_message_16.png"
                OnClientClick="javascript:return opendiv();" /><asp:Button Style="background-image: none;
                    cursor: hand; border-top-style: none; border-right-style: none; border-left-style: none;
                    background-color: transparent; border-bottom-style: none" ID="btncompose" runat="server"
                    Height="18px" Text="Compose Message" Width="121px" BorderStyle="None" OnClientClick="javascript:return opendiv();"
                    CausesValidation="False"></asp:Button></td>
    </asp:Panel>
</TR>
    <tr>
        <td style="height: 12px">
        </td>
        <td align="left">
           </td>
        <td align="left" >
        </td>
        <td style="width: 4px; height: 12px; background-color: transparent">
        </td>
    </tr>
</TBODY></TABLE>
    <table cellpadding="0" cellspacing="0" style="border-right: #000000 1px ridge; border-top: #000000 1px ridge;
        border-left: #000000 1px ridge; width: 752px; border-bottom: #000000 1px ridge;
        background-color: #ffffff">
        <tr>
            <td align="right" style="width: 2px; height: 23px">
                &nbsp;</td>
            <td align="right" style="width: 2px; height: 23px">
                &nbsp;</td>
            <td align="right" style="width: 2px; height: 23px">
            </td>
            <td align="right" style="width: 1px; height: 23px; background-color: white">
                &nbsp;
            </td>
            <td align="left" style="width: 168px; height: 23px; background-color: white">
                <asp:Label ID="Label17" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="11pt"
                    ForeColor="Red" Text="NOTE :"></asp:Label></td>
            <td align="left" style="font-size: 12pt; width: 1px; color: #000000; font-family: Times New Roman;
                height: 23px; background-color: white">
            </td>
            <td align="left" style="font-size: 12pt; color: #000000; font-family: Times New Roman;
                background-color: white">
            </td>
            <td align="left" style="font-size: 12pt; color: #000000; font-family: Times New Roman;
                height: 23px">
            </td>
        </tr>
        <tr style="font-size: 12pt; color: #000000; font-family: Times New Roman">
            <td style="width: 2px; height: 23px">
                &nbsp;</td>
            <td style="width: 2px; height: 23px">
                &nbsp;</td>
            <td style="width: 2px; height: 23px">
            </td>
            <td style="width: 1px; height: 23px; background-color: white">
            </td>
            <td align="left" style="width: 168px; height: 23px; background-color: white">
                <asp:Label ID="Label18" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="10pt"
                    Text="Last Updated Location" Width="168px"></asp:Label></td>
            <td align="left" style="width: 1px; height: 23px; background-color: white">
                <asp:Label ID="Label23" runat="server" Font-Bold="True" Text=":"></asp:Label></td>
            <td align="left" style="background-color: white; height: 23px;">
                &nbsp;<asp:Label ID="Label20" runat="server" Font-Names="Verdana" Font-Size="10pt"
                    Text="Location has  not be changed seen given time" Width="312px"></asp:Label></td>
            <td align="left" style="height: 23px">
            </td>
        </tr>
        <tr>
            <td style="width: 2px; height: 25px">
                &nbsp;</td>
            <td style="width: 2px; height: 25px">
                &nbsp;</td>
            <td style="width: 2px; height: 25px">
            </td>
            <td style="width: 1px; height: 25px; background-color: white">
            </td>
            <td align="left" style="width: 168px; height: 25px; background-color: white">
                <asp:Label ID="Label19" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="10pt"
                    Text="Buddy Status"></asp:Label></td>
            <td align="left" style="width: 1px; height: 25px; background-color: white">
                <asp:Label ID="Label24" runat="server" Font-Bold="True" Text=":"></asp:Label></td>
            <td align="left" style="background-color: white; height: 25px;">
                &nbsp;<asp:Image ID="Image1" runat="server" Height="12px" ImageAlign="AbsMiddle"
                    ImageUrl="../Images/on.png" />
                &nbsp;<asp:Label ID="Label21" runat="server" Font-Names="Verdana" Font-Size="10pt"
                    Text="Active Buddy" Width="96px"></asp:Label>
                &nbsp;
                <asp:Image ID="Image3" runat="server" Height="12px" ImageAlign="AbsMiddle" ImageUrl="../Images/gray_16x16.png" />
                <asp:Label ID="Label22" runat="server" Font-Names="Verdana" Font-Size="10pt" Text="InActive Buddy"
                    Width="104px"></asp:Label></td>
            <td align="left" style="height: 25px">
            </td>
        </tr>
        <tr>
            <td style="width: 2px; height: 25px">
                &nbsp;</td>
            <td style="width: 2px; height: 25px">
                &nbsp;</td>
            <td style="width: 2px; height: 25px">
                &nbsp;</td>
            <td style="width: 1px; height: 25px; background-color: white">
            </td>
            <td align="left" style="width: 168px; height: 25px; background-color: white">
                <asp:Label ID="Label29" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="10pt"
                    Text="Speed"></asp:Label></td>
            <td align="left" style="width: 1px; height: 25px; background-color: white"><asp:Label ID="Label30" runat="server" Font-Bold="True" Text=":"></asp:Label>
            </td>
            <td align="left" style="background-color: white">
                &nbsp;<asp:Label ID="Label32" runat="server" Font-Names="Verdana" Font-Size="10pt"
                    Text="Unit of speed in Km/Hr"></asp:Label></td>
                              
            <td align="left" style="height: 25px">
            </td>
        </tr>
        <tr>
            <td align="left" style="background-color: white">
                &nbsp;</td>
            <td align="left" style="background-color: white">
                &nbsp;</td>
            <td align="left" style="background-color: white" colspan="5">
                &nbsp;&nbsp;<asp:Label ID="Label5" runat="server" Font-Names="Verdana" Font-Size="9pt"
                    Text="Time displayed will depend on the GMT Settings selected for the  buddy. "
                    ForeColor="Maroon" Width="726px" Font-Bold="True"></asp:Label></td>
        </tr>
        <tr>
            <td align="left" style="background-color: white">
                &nbsp;</td>
            <td align="left" style="background-color: white">
                &nbsp;</td>
            <td align="left" style="background-color: white" colspan="5">
                &nbsp;&nbsp;<asp:Label ID="Label6" runat="server" Font-Names="Verdana" Font-Size="9pt"
                    Text="The GPS Location accuracy depends on the GPS Chip in the Mobile Handset / Tracking device. "
                    ForeColor="Maroon" Width="726px" Font-Bold="True"></asp:Label></td>
        </tr>
    </table>
    &nbsp;&nbsp; 
</TD></TR></TBODY></TABLE>
    <div style="display: none" id="dwnloadbackup">
        <table style="border-top-width: 1px; border-left-width: 1px; border-left-color: maroon;
            border-bottom-width: 1px; border-bottom-color: maroon; width: 512px; border-top-color: maroon;
            border-right-width: 1px; border-right-color: maroon" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td style="font-weight: bold; background-color: #d7f0f4; height: 411px;" valign="top"
                        align="left">
                        <table style="width: 496px; height: 368px;">
                            <tbody>
                                <tr>
                                    <td style="width: 51px; height: 13px">
                                    </td>
                                    <td style="width: 731px; height: 13px" align="right">
                                        <asp:Label ID="Label2" runat="server" ForeColor="Maroon" Font-Size="Small" Font-Names="Verdana"
                                            Text="(0 chrs.)" Width="250px"></asp:Label></td>
                                    <td style="width: 1167px; height: 13px">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 51px; height: 72px">
                                    </td>
                                    <td style="width: 731px" align="left">
                                        <asp:TextBox Style="overflow: hidden; height: auto" ID="txtMessage" oncopy="event.KeyCode=1000;"
                                            oncut="event.KeyCode=1000;" onpaste="event.KeyCode=1000;" runat="server" CssClass="margin1"
                                            Height="220px" Width="528px" MaxLength="1000" TextMode="MultiLine" Rows="15"></asp:TextBox>
                                    </td>
                                    <td style="width: 1167px; height: 72px">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 51px; height: 46px">
                                    </td>
                                    <td style="width: 731px; height: 46px" align="left">
                                        &nbsp;<asp:CheckBox ID="Chekbxmoblno" onclick="javascript:enableExterNameTextBox(this)"
                                            runat="server"></asp:CheckBox>
                                        <asp:Label ID="lblmobilno" runat="server" Font-Size="14px" Font-Names="Verdana" Text="Enter Remote Mobile Number"></asp:Label>
                                        &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
                                        &nbsp;<asp:TextBox ID="txtmoblno" onkeypress="return isNumberKey(event)" runat="server"
                                            Width="528px" MaxLength="25" BackColor="Silver" Enabled="False"></asp:TextBox></td>
                                    <td style="width: 1167px; height: 46px">
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 51px;">
                                    </td>
                                    <td style="width: 731px;" align="right">
                                        <table>
                                            <tr>
                                                <td style="width: 129px">
                                                    &nbsp;</td>
                                                <td style="width: 100px">
                                                    <asp:Panel ID="pancompose" runat="server">
                                                        <table style="width: 136px">
                                                            <tr>
                                                                <td style="border-right: #000000 1px ridge; border-top: #000000 1px ridge; background-image: url(../Images/bgcolor.gif);
                                                                    border-left: #000000 1px ridge; width: 175px; border-bottom: #000000 1px ridge;
                                                                    height: 21px; background-color: transparent">
                                                                    <asp:ImageButton ID="imgsendmessage" runat="server" ImageAlign="AbsBottom" ImageUrl="../Images/compose_message_16.png"
                                                                        OnClick="imgsendmessage_Click" OnClientClick="javascript:return chekboxalert_onclick();" /><asp:Button
                                                                            ID="btnSendBackup" runat="server" BorderStyle="None" CausesValidation="False"
                                                                            Font-Names="Verdana" Font-Size="9pt" OnClick="btnSendBackup_Click" OnClientClick="javascript:return chekboxalert_onclick();"
                                                                            Style="background-image: none; cursor: hand; border-top-style: none; border-right-style: none;
                                                                            border-left-style: none; background-color: transparent; border-bottom-style: none"
                                                                            Text="Send Message" Width="96px" />&nbsp;</td>
                                                            </tr>
                                                        </table>
                                                    </asp:Panel>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="width: 129px">
                                                </td>
                                                <td style="width: 100px">
                                                </td>
                                            </tr>
                                        </table>
                                        &nbsp;
                                    </td>
                                    <td style="width: 1167px;">
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
   <DIV style="DISPLAY: none;" id="Divinvite">
       <br />
       <br />
       &nbsp;</DIV> 
 
   
      </TD><TD vAlign=top align=left style="width: 1px"></TD></TR></TBODY></TABLE></TD></TR></tbody></table>
      
                <asp:HiddenField ID="hdnid" runat="server" />
                <asp:HiddenField ID="hdnstatus" runat="server" />
                <asp:HiddenField ID="hdnquery" runat="server" />
            </td>
        </tr>
    </table>    
    <asp:HiddenField ID="Hiddenimage" runat="server" />
    <asp:HiddenField ID="hdnval" runat="server" />
    <asp:HiddenField ID="hdnval2" runat="server" />
    <asp:HiddenField ID="HiddenField1" runat="server" />
 </asp:Content>
--------------------------------------------------------------------------------------------
Here is the buddy.aspx.cs page below.........
--------------------------------------------------------------

using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using net.microlifeline.www;

public partial class Buddy : System.Web.UI.Page
{
   // string strglobloc = "";
    MyConnection Con = new MyConnection();    
    SqlCommand Sqlcmd = new SqlCommand();
    net.microlifeline.www.WebService webs = new net.microlifeline.www.WebService();
    string user = "";
    string cnt;
    string status = "";

    public static string cn,cn1,cn2,total;
    public static string sqlQuery = "";
    
    protected void Page_Load(object sender, EventArgs e)
    {  
        //Page.ClientScript.RegisterStartupScript(Me.GetType()."Refresh","window.setTimeout('var url = window.location.href;window.location.href = url',1000);",true)       
        /*****On pressing Enter buuton search button will pressed*********************/
        txtSearch.Attributes.Add("onKeyPress", "goClick('" + imgbtnSearch.ClientID + "',event)");
        
        
        /*****Checking the session value**********************/       
        if ((Session["orgid"] ==null) || (Session["orgid"].ToString() == ""))
        {           
                Response.Redirect("SessionExpired.aspx?type=nocookies");         
        }
        else
        {
            user = Session["orgid"].ToString();
           
            /*****The textcounter counts the text in message box *******/
            txtMessage.Attributes.Add("onkeydown", "textCounter(this,'" + Label2.ClientID + "', 1000)");
            txtMessage.Attributes.Add("onkeyup", "textCounter(this,'" + Label2.ClientID + "', 1000)");
            txtMessage.Attributes.Add("onmousedown", "textCounter(this,'" + Label2.ClientID + "', 1000)");
            txtMessage.Attributes.Add("onmouseup", "textCounter(this,'" + Label2.ClientID + "', 1000)");
            txtMessage.Attributes.Add("onblur", "textCounter(this,'" + Label2.ClientID + "', 1000)");

            if (!Page.IsPostBack)
            {
                fnbindbuddylist("PAGELOAD");
            }
       }
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label112.Text = DateTime.Now.ToString();
        UpdatePanel1.Update();
        //gvCheckboxes.DataBind();
        //this.gvCheckboxes.DataBind();
    }  

    void fnbindbuddylist(String strPageLoad)
    {
        status = ddlstatus.Text.Trim().ToUpper();

        string srch = txtSearch.Text.Replace("'", "''");
        srch = srch.Replace("_", "/_");
        srch = srch.Replace("%", "[%]");
        srch = srch.Replace(" ", "");

        sqlQuery = "Buddyinfo '" + user + "','" + srch + "','" + status + "'";
        hdnquery.Value = sqlQuery;
        BindGridView(sqlQuery, strPageLoad);                    

        if (Session["orgid"].ToString() == "5")
        {
            Label14.Visible = false;
            ImageButton4.Visible = false;
            ImageButton3.Visible = false;
            Label9.Visible = false;
        }
        if (Session["orgid"].ToString() == "6")
        {
            pancompose.Enabled = false;
        }

    }  
        
    /****This binds data im gridview *********/
    protected void BindGridView(string strsql,string strPageLoad)
    {
        try
        {
            if (Con.SqlConn_BTS.State == ConnectionState.Open)
                Con.SqlConn_BTS.Close();
            Con.SqlConn_BTS.Open();

            SqlDataAdapter sda = new SqlDataAdapter(strsql, Con.SqlConn_BTS);
            sda.SelectCommand.CommandTimeout = 600;
            DataSet ds = new DataSet();
            sda.Fill(ds, "userdetails");
            
            ViewState["ds"] = ds.Tables["userdetails"].Rows.Count;

            if (strPageLoad == "PAGELOAD")
            {
                if (ds.Tables["userdetails"].Rows.Count == 0)
                {
                    strsql = strsql.Replace("'ACTIVE'", "'INACTIVE'");
                    sda = new SqlDataAdapter(strsql, Con.SqlConn_BTS);
                    sda.SelectCommand.CommandTimeout = 600;
                    ds = new DataSet();
                    sda.Fill(ds, "userdetails");
                    ddlstatus.SelectedIndex = 1;                    
                    status = "INACTIVE";
                    hdnval2.Value = "0";
                    
                }
            }

            if(status=="ACTIVE")
            {
                cn = Convert.ToString(ds.Tables["userdetails"].Rows.Count);
                lblCnt.Text = "Active Buddies" +"";
                lblcnt1.Text = cn;
                hdnval2.Value = cn;
                
            }
            else if (status == "INACTIVE")
            {
                cn1 = Convert.ToString(ds.Tables["userdetails"].Rows.Count);
                hdnval.Value = Convert.ToString(Convert.ToInt32(hdnval2.Value) + Convert.ToInt32(cn1));
                total = hdnval.Value;                
                lblCnt.Text = "Inactive Buddies" + " ";
                lblcnt1.Text = cn1 + "/" + total;

               
            }
            else
            {
                cn2 = Convert.ToString(ds.Tables["userdetails"].Rows.Count);
                lblCnt.Text = "Active Buddies" + " ";
                lblcnt1.Text = hdnval2.Value + "/" + cn2;
            } 

            gvCheckboxes.DataSource = ds.Tables["userdetails"].DefaultView;
            gvCheckboxes.DataBind();

            if (Convert.ToInt32(ViewState["ds"]) == 0)
            {
                panadd.Enabled = false;
            }
            else
            {
                lnkbtnViewAll.Attributes.Add("onclick", "javascript:return winopenmulti()");
                panadd.Enabled = true;
                panviewall.Enabled = true;
            }
        }        
        catch(Exception ex)
        {
                 MessageBox.Show(ex.Message); 
        }
        //UpdatePanel1.Update();
    }
   
         
    /****This binds details of buddy in required field ***************/
    protected void gvCheckboxes_RowDataBound(object sender, GridViewRowEventArgs e)
    {
     try
     {
        
         if (e.Row.RowType == DataControlRowType.Header)
         {
             //Find the checkbox control in header and add an attribute
             ((CheckBox)e.Row.FindControl("chkBxHeader")).Attributes.Add("onclick", "javascript:SelectAll('" + ((CheckBox)e.Row.FindControl("chkBxHeader")).ClientID + "')");
         }
         if (e.Row.RowType == DataControlRowType.DataRow)
         {
             /****Storing databse's values in string***************/
             String intemergencyid = DataBinder.Eval(e.Row.DataItem, "intemergenctid").ToString();
             String Emergencydatetime = DataBinder.Eval(e.Row.DataItem, "Emergencydatetime").ToString();
             String onofftransit = DataBinder.Eval(e.Row.DataItem, "trasit").ToString();
             String strspeed = DataBinder.Eval(e.Row.DataItem, "Vchspeed").ToString();
             String gpstime = DataBinder.Eval(e.Row.DataItem, "dtgpslocationdatetime").ToString();
             String ctime = DataBinder.Eval(e.Row.DataItem, "ctime").ToString();
             String vchCurrentlocation = DataBinder.Eval(e.Row.DataItem, "vchCurrentlocation").ToString();
             String handsetmodel_No = DataBinder.Eval(e.Row.DataItem, "vchhandsetmodel_No").ToString();
             String gps = DataBinder.Eval(e.Row.DataItem, "chrgpsstatus").ToString();
             String locate = DataBinder.Eval(e.Row.DataItem, "chrStatusLocation").ToString().Trim();
             String gpshandset = DataBinder.Eval(e.Row.DataItem, "vchHandset").ToString();
             String userphoto = DataBinder.Eval(e.Row.DataItem, "photo").ToString();
             String locate1 = DataBinder.Eval(e.Row.DataItem, "location").ToString().Trim();
             String latlong = DataBinder.Eval(e.Row.DataItem, "vchlocation").ToString();
             String dtdatlocation = DataBinder.Eval(e.Row.DataItem, "currentgpsdatestaus").ToString().Trim();
             String strname = DataBinder.Eval(e.Row.DataItem, "name").ToString();
             String userid = DataBinder.Eval(e.Row.DataItem, "intuserid").ToString();             
             String Transitdatetime = DataBinder.Eval(e.Row.DataItem, "Transitdatetime").ToString().Trim();
             String vchcellid = DataBinder.Eval(e.Row.DataItem, "vchcellid").ToString();
             String date = DataBinder.Eval(e.Row.DataItem, "Date").ToString();
             String batterylevel = DataBinder.Eval(e.Row.DataItem, "intcurrentbatterylevel").ToString();
             String accle = DataBinder.Eval(e.Row.DataItem, "vchacceleration").ToString();

             Label lblDatelocation1 = (Label)e.Row.FindControl("lbldtlocation1");
             Label lblDatelocation2 = (Label)e.Row.FindControl("lbldtlocation2");
             Label pipe = (Label)e.Row.FindControl("lblpipe");
             Label pipe2 = (Label)e.Row.FindControl("lblpipe2");
             Label pipe3 = (Label)e.Row.FindControl("lblpipe3");
             Label lblModel = (Label)e.Row.FindControl("lblModel");
             Label lblreject = (Label)e.Row.FindControl("Label7");
             Label lbllocation = (Label)e.Row.FindControl("lbllocation");
             Label lblnotavlbl = (Label)e.Row.FindControl("lblnotavlable");
             Label lblnotdate = (Label)e.Row.FindControl("lblnotdate");
             Label lblbatteryper = (Label)e.Row.FindControl("lblbatteryper");
             Label acceleration = (Label)e.Row.FindControl("lblaccelaration");
             ImageButton rejectimagbuton = (ImageButton)e.Row.FindControl("imagreinvited");
             HyperLink link = (HyperLink)e.Row.FindControl("HyperLink5");
             Image imgbattery = (Image)e.Row.FindControl("imgbattery");
             ImageButton img = (ImageButton)e.Row.FindControl("Replayimage");
             ImageButton img1 = (ImageButton)e.Row.FindControl("Googleimage");
             ImageButton img2 = (ImageButton)e.Row.FindControl("ImageButton5");
             ImageButton img3 = (ImageButton)e.Row.FindControl("ImageButton7");
             Button strglobloc1 = (Button)e.Row.FindControl("Button2");

             if (ddlstatus.SelectedItem.Text == "Active")
             {
                 strglobloc1.Visible = false;
             }
             else if (ddlstatus.SelectedItem.Text == "All")
             {
                 if (onofftransit == "../Images/on.png")
                 {
                     strglobloc1.Visible = false;
                 }
                 else
                 {
                     strglobloc1.Visible = true;
                 }
             }
             else
             {
                 strglobloc1.Visible = true;
                 
             }
             
             
               


             if (accle == "")
             {
                 acceleration.Text = "0.00 m/s2";
             }
             else
             {
                 acceleration.Text = accle.ToString()+"m/s2";
             }

             string[] dt= gpstime.Split(Convert.ToChar(" "));
             string startdate = dt[0];
             string[] strdate1= startdate.Split(Convert.ToChar("/"));
             string startdatemt = "";           
             string enddatemt ="";

             if (!string.IsNullOrEmpty(gpstime))
             {
                startdatemt = strdate1[2] + "-" + strdate1[0] + "-" + strdate1[1] + " " + "00:00:00";
                enddatemt = strdate1[2] + "-" + strdate1[0] + "-" + strdate1[1] + " " + "23:59:59";
             }

             string enddate = gpstime;
             DateTime dttime = System.DateTime.Now;

             // If Location is outside India Hide the MTIL Maps
             if (!(locate1.Trim().Contains("India")))
             {
                 img.Visible = false;
                 pipe3.Visible = false;
             }
             else
             {
                 img.Attributes.Add("onclick", "javascript:return openzicom('" + strname + "','" + gpshandset + "','" + startdatemt + "','" + enddatemt + "')");
             }

             // Show all Maps

             img1.Attributes.Add("onClick", "javascript:return winopen('" + gpshandset + "','" + strname + "','" + startdate + "','" + enddate + "','" + userphoto + "','" + userid + "','" + handsetmodel_No + "'); return false;");
             img2.Attributes.Add("onClick", "javascript:return winopenmlive('" + gpshandset + "','" + strname + "','" + startdate + "','" + enddate + "','" + userphoto + "','" + userid + "','" + handsetmodel_No + "'); return false;");
             img3.Attributes.Add("onClick", "javascript:return winopenyahoo('" + gpshandset + "','" + strname + "','" + startdate + "','" + enddate + "','" + userphoto + "','" + userid + "','" + handsetmodel_No + "'); return false;");

                                
             Image imgonoff = (Image)e.Row.FindControl("imgonoff");
             CheckBox check1 = (CheckBox)e.Row.FindControl("CheckBox");
                 
             link.Visible = true;
             lblModel.Text = handsetmodel_No;

             // Shows Handset Model of the Buddy
             if (handsetmodel_No!="")
                 link.Text = "<b>"+strname +"</b>"+ "<br>[" + lblModel.Text + "]";
             else
                 link.Text = "<b>" + strname + "</b>";

             // Shows the Battery Level
             lblbatteryper.Text = batterylevel.Trim() + "" + "%";

             string[] strarray = {"",""};
             string todaytime = "";

             if ((gps == "N") && (Transitdatetime != ""))
             {
                   strarray = Transitdatetime.Split(Convert.ToChar(" "));
                   todaytime = Transitdatetime;
             }
             else if ((gps == "Y") && (dtdatlocation != ""))
             {
                   strarray = dtdatlocation.Split(Convert.ToChar(" "));
                   todaytime = dtdatlocation;
             }
             else
             {
                   lblDatelocation2.Text = "--NA--";
             }

             int length1 = strarray.Length;

             if (length1 == 4)
             {
                   // If Transit DateTime is of Before Today then show Date as well as Time 
                   lblDatelocation1.Text = strarray[0].ToString() + " " + strarray[1].ToString() + " ";
                   lblDatelocation2.Text = strarray[2].ToString() + " " + strarray[3].ToString();
             }
             else
             {
                 lblDatelocation1.Text = dtdatlocation.ToString();
             }
                                              
             
                 imgonoff.ToolTip = Transitdatetime;

                 Label lbllast = (Label)e.Row.FindControl("lbllast");
                 Label lbllocationc = (Label)e.Row.FindControl("lbllocationc");

                 // If the Location is 'Not Available'
                 if ((vchCurrentlocation == "--Not Available--") || (ctime== "--Not Available--"))
                 {
                     string strdate = System.DateTime.Now.ToShortTimeString();

                     lbllocationc.Visible = true;
                     lbllast.Visible = true;
                     lbllast.Text = "Last seen at ";
                     lbllocationc.Text ="--Location Not Available--";                     
                 }                 
                 // If GPS Location is not available then show Cell ID   
                 if ((locate1 == "") || (locate1 == "location") || (locate1 == "Location"))
                 {
                     lbllocation.Text = vchcellid;

                     if (vchcellid == "")
                     {
                         lblnotavlbl.Visible = true;
                     }
                 }
                 else
                 {
                     lbllocation.Text = locate1;

                 }
             
                 /******************For International Location if Location is "N.A" *********************/
                 if ((vchCurrentlocation == "--N.A--"))
                 {
                     if (ctime == "--Not Available--")
                     {
                         lbllast.Visible = true;
                         lbllocationc.Visible = true;
                         lbllast.Text = "Last seen at ";
                         lbllocationc.Text = "--Location Not Available--";
                         string[] strlocation = locate1.Split(Convert.ToChar(','));
                         lbllocation.Text = strlocation[0].Substring(34) + " " + locate1.Substring(7);
                     }
                     else
                     {
                         lbllast.Visible = false;
                         lbllocationc.Visible = false;
                         string[] strlocation = locate1.Split(Convert.ToChar(','));
                         lbllocation.Text = strlocation[0].Substring(34) + " " + locate1.Substring(7);
                     }
                 }
              
               //*********Speed calculation************/lblstate
               Label lblstate = (Label)e.Row.FindControl("lblstate");
               Label lblspeed = (Label)e.Row.FindControl("Label2");
               
               if (onofftransit== "../Images/on.png")
               {
                   if (strspeed != "-N.A-")
                   {
                       if (Convert.ToDouble(strspeed) != 0)
                       {
                           lblstate.Text = "Transit";
                           lblspeed.ForeColor = System.Drawing.Color.Green;
                           lblspeed.Text = strspeed+" km/h";
                       }
                       else
                       {
                           lblstate.Text = "Idle";
                           lblspeed.ForeColor = System.Drawing.Color.Red;
                           lblspeed.Text = strspeed + " km/h";
                       }
                   }
                   else
                   {
                       lblspeed.ForeColor = System.Drawing.Color.Red;
                       lblspeed.Text = "0.00 km/h";
                       lblstate.Text = "Idle";
                   }
               }
               else
               {
                   lblspeed.ForeColor = System.Drawing.Color.Red;
                   lblspeed.Text = "0.00 km/h";
                   lblstate.Text = "Idle";
               }             

             //***********************EmergencyMap******//
               ImageButton imgEM = (ImageButton)e.Row.FindControl("imgEmergency");
               Label lbldateEM = (Label)e.Row.FindControl("lblemergencylastdate");
             
             if (!(string.IsNullOrEmpty(intemergencyid)))
             {
                 imgEM.Attributes.Add("onClick", "javascript:return fnEmergencyMap('" + userid + "');");
                 lbldateEM.Text = Emergencydatetime;
              }
             else
             {
                imgEM.Visible=false;
                lbldateEM.Text="-NA-";
             }
            //**********************End **EmergencyMap******//
             }
             //strglobloc = locate1;     
          } 
        
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message); 
        }
    }
   
    /***Button for Sending message***********/
    protected void btnSendBackup_Click(object sender, EventArgs e)
    {
            sendmessage();
    }
   
    /**Sending Message , Insert in Messages1 Table******/
    protected void sendmessage()
    {
        try
        {
            int Num;
            Num = gvCheckboxes.Rows.Count;
            string currentRowsFilePath = "";
            string orgName = Convert.ToString(Session["orgname"]);
            string ResultValue = "";
          
            for (int index1 = 0; index1 < Num; index1++)
            {              
                CheckBox cb = (CheckBox)(gvCheckboxes.Rows[index1].FindControl("CheckBox"));
                             
               if (cb.Checked == true)
                {                   
                    if (ResultValue == "")
                    {                       
                        ResultValue = gvCheckboxes.DataKeys[index1].Value.ToString();
                    }
                    else
                    {                        
                        ResultValue = ResultValue + "," + gvCheckboxes.DataKeys[index1].Value.ToString();
                    }                   
                }
            }       
                string ContactNo = Session["mobno"].ToString();
                string remotContactNo = txtmoblno.Text;
                string Sql;
                string orgid="";
                orgid=Session["orgid"].ToString();
                if (orgid == "")
                {
                    orgid = null;
                }        
                      
                if (remotContactNo !="")
                {                
                    Sql = "ComposeMessage '"+txtMessage.Text+"',"+orgid+",'"+ResultValue+"','"+remotContactNo+"','"+orgName+"',"+orgid+""; 
                }
                else
                {                
                    Sql = "ComposeMessage '" + txtMessage.Text + "'," + orgid + ",'" + ResultValue + "','','" + orgName + "'," + orgid + ""; 
                }
               
                Sqlcmd.Connection = Con.SqlConn_BTS;
                if (Con.SqlConn_BTS.State == ConnectionState.Open)
                    Con.SqlConn_BTS.Close();
                Sqlcmd.CommandText = Sql;
                Sqlcmd.CommandTimeout = 600;
                Sqlcmd.Connection.Open();
                Sqlcmd.ExecuteNonQuery();
                Sqlcmd.Connection.Close();
                Page.ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Message Sent Succesfully.');</script>");          
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message); 
        }
    }  
    /*imagebutton for sending message*/
    protected void imgsendmessage_Click(object sender, ImageClickEventArgs e)
    {
        sendmessage();
    }     
     
    protected void imgbtnSearch_Click(object sender, ImageClickEventArgs e)
    {
        fnbindbuddylist("");
    }
    protected void btnAll_Click(object sender, EventArgs e)
    {
        txtSearch.Text = "";
        //Page_Load(sender,e);
        fnbindbuddylist(""); 
    }

    protected void ImageButton6_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("buddy.aspx");
    }

    protected void ddlstatus_SelectedIndexChanged(object sender, EventArgs e)
    {
        fnbindbuddylist("");
      
    }
         
    protected void btnStatus_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            gvCheckboxes.SelectedIndex = ((GridViewRow)((ImageButton)sender).Parent.Parent).DataItemIndex;
            string id = gvCheckboxes.DataKeys[gvCheckboxes.SelectedIndex].Value.ToString();

            string sql = "select  vchmobilecountry+vchmobileno as mobile,vchfirstname+' '+isnull(vchlastname,'') as [name] from userdetails where intuserid=" + id + "";
            DataSet dssql;
            dssql = Con.GetData(sql);
            string mobile = dssql.Tables[0].Rows[0]["mobile"].ToString();
            string name = dssql.Tables[0].Rows[0]["name"].ToString();
            if (dssql.Tables[0].Rows.Count != 0)
            {
                webs.SendSms("8", "215866", "BTS FIND", mobile, "SendLONG");
                MessageBox.Show("Status request message sent successfully to "+name+". Status will be soon updated on the website..");
            }
            else
            {
                MessageBox.Show("Message not send due unavailble mobile no.");
            }

        }
        catch (Exception ex)
        {

        }
    }

    
    protected void Button2_Click(object sender, EventArgs e)
    {
         try
        {
           
            gvCheckboxes.SelectedIndex = ((GridViewRow)((Button)sender).Parent.Parent).DataItemIndex;
            string id = gvCheckboxes.DataKeys[gvCheckboxes.SelectedIndex].Value.ToString();

            string sql = "select vchmobilecountry+vchmobileno as mobile,vchfirstname+' '+isnull(vchlastname,'') as [name],vchgpslocation as location from userdetails where intuserid=" + id + "";
            DataSet dssql;
            dssql = Con.GetData(sql);
          
            string mobile = dssql.Tables[0].Rows[0]["mobile"].ToString();
            string name = dssql.Tables[0].Rows[0]["name"].ToString();
            string location = dssql.Tables[0].Rows[0]["location"].ToString();
            if (dssql.Tables[0].Rows.Count != 0)
            {

                webs.SendSms("8", "215866", "Your Micro BTS status is showing Inactive as last data we have received at "+  location +" , Please restart the Handset. Regards, Swapnil Surve (SIS)", mobile, "SendLONG");
                MessageBox.Show("Message sent successfully to " + name + ".");
            }
            else
            {
                MessageBox.Show("Message not send due unavailble mobile no.");
            }

        }
        catch (Exception ex)
        {

        }
    }
}



 
   
  

  Shailendrasinh Parmar replied to Bikash Samal
15-Nov-10 06:43 AM
I saw your code, and found this event

protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label112.Text = DateTime.Now.ToString();
        UpdatePanel1.Update();
        //gvCheckboxes.DataBind();
        //this.gvCheckboxes.DataBind();
    }  

You need to re-bind the data in gridview and also update the update panel at the same time. So try following

protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label112.Text = DateTime.Now.ToString();
gvCheckboxes.DataBind();
        UpdatePanel1.Update();
    }  

  Bikash Samal replied to Shailendrasinh Parmar
15-Nov-10 10:56 PM
Ya u r right upto some how....
but this is not the right solution.........
The right solution is...................................

protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label112.Text = DateTime.Now.ToString();
        UpdatePanel1.Update();
         fnbindbuddylist("PAGELOAD");
    }  

In ur view u are right, but my gridview bind this data that is in page_load's IsPostback method.

Anyways thanks a lot for giving me ur precious time.
  Shailendrasinh Parmar replied to Bikash Samal
15-Nov-10 11:04 PM
But for binding data you can create the method like 

private void BindGridData()
{
// your logic to bind data in gridview
}

and you can call this method whenever you require. Like, on page_load you will first need this, again after few minutes, to refresh the data you again need this method.  So, writing the logic to bind the data in another function is more useful than directly write the code to bind data in page_load event.

Hope this helps.
  Bikash Samal replied to Shailendrasinh Parmar
15-Nov-10 11:43 PM
Ya, thats the right way...and I agree with u....
As u told that I've to create a bindgridview method to bind data, thats right and it is as fnbindbuddylist() in my code u can see too......
My problem is that I've given a created project with no documentation and no advisor means there is nobody who created that project......
And I'm a fresher too. So I'm facing so many problems......
means dont know all the databases, stored procedures......

Anyways thanks a lot for giving me such ideas to solve my problems.....
Have a good day...... 

  Shailendrasinh Parmar replied to Bikash Samal
15-Nov-10 11:52 PM
You are welcome, Bikash !!!
Create New Account
help
ControlToValidate = "ddlContactName" InitialValue = "-1"> * < / asp : RequiredFieldValidator > < / FooterTemplate > < / asp : TemplateField > < / Columns > protected void gvContacts_RowDataBound( object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType = = DataControlRowType .Footer) { DropDownList ddlContactName = ( DropDownList )gvContacts.FooterRow.FindControl( "ddlContactName" ); ddlContactName.SelectedIndexChanged + = new EventHandler (ddlContactName_SelectedIndexChanged); ddlContactName.AutoPostBack in RowDataBound event also. Hi Try to Do like this protected void GridView1_RowDataBound( object sender, GridViewRowEventArgs e) { if (e.Row.RowType ! = DataControlRowType.Footer) { / / do the binding for the normal rows ddl.SelectedIndexChanged + = new EventHandler(ddl_SelectedIndexChanged); } } Now implement e) { throw new NotImplementedException(); } Hi Try to Do like this protected void GridView1_RowDataBound( object sender, GridViewRowEventArgs e) { if (e.Row.RowType ! = DataControlRowType.Footer) { / / do the binding for the normal rows ddl.SelectedIndexChanged + = new EventHandler(ddl_SelectedIndexChanged); } } Now implement e) { throw new NotImplementedException(); } Hi Try to Do like this protected void GridView1_RowDataBound( object sender, GridViewRowEventArgs e) { if (e.Row.RowType ! = DataControlRowType.Footer) { / / do the binding for the normal rows ddl.SelectedIndexChanged + = new EventHandler(ddl_SelectedIndexChanged); } } Now implement
function doFocus(key) { if(key = = 13) document.getElementById('Button2').focus(); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { ((TextBox)e.Row.Cells[11].FindControl("TextBox2")).Attributes.Add("onkeydown", "doFocus(window.event.keyCode in the Edit mode before you add the attribute: [CODE] protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.CommandName = = "Edit") ((TextBox)e.Row.Cells[11].FindControl("TextBox2")).Attributes.Add("onkeydown handler of button to save numbers entered in Textbox. . . [CODE] private void RowDataBound_GridView(object sender, GridViewRowEventArgs e) { if(e.Row.RowState = = DataControlRowState.Edit) { if (e.Row.RowType = = DataControlRowType.DataRow) { YourTextBoxID.Attributes.Add("onkeydown", "if(event.which | | event.keyCode){if ((event.which = = 13) | | (event getElementById('" + button1.UniqueID + "').click();return false;}} else {return true}; "); } } } [ / CODE] protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { - --I need to be able to assign a index variable?? GridViewRow row = GridView1.Rows Cells[11].FindControl("TextBox2")).Text; if (e.Row.RowState = = DataControlRowState.Edit) { if (e.Row.RowType = = DataControlRowType.DataRow) { TX2.Attributes.Add("onkeydown", "if(event.which | | event.keyCode){if ((event.which = = 13) | | (event Row.Cells[13].FindControl("TextBox2")); if (e.Row.RowState = = DataControlRowState.Edit) { if (e.Row.RowType = = DataControlRowType.DataRow) { TX2.Attributes.Add("onkeydown", "if(event.which | | event.keyCode){if ((event.which = = 13) | | (event during the Edit mode: [CODE] if (e.Row.RowState = = DataControlRowState.Edit) { if (e.Row.RowType = = DataControlRowType.DataRow) { TextBox TX2 = ((TextBox)e.Row.Cells[13].FindControl("TextBox2")); TX2.Attributes.Add("onkeydown", "if
Web; using System.Web.UI; using System.Web.UI.WebControls; public class GridViewTemplate : ITemplate { private DataControlRowType templateType; private string columnNameFriendly; private string columnNameData; private Control control; public GridViewTemplate(DataControlRowType type, string colNameFr, string colNameDt, Control con) { templateType = type; columnNameFriendly = colNameFr; columnNameData = colNameDt; control = con public void InstantiateIn(System.Web.UI.Control container) { switch (templateType) { case DataControlRowType.Header: { Literal lc = new Literal(); lc.Text = columnNameFriendly; container.Controls.Add(lc); break ; } case DataControlRowType.DataRow: { Control field = control; field.DataBinding + = new EventHandler( this .field_DataBinding); container.Controls.Add(field); break UpdateCommandType = SqlDataSourceCommandType.StoredProcedure; sqlDataSource.DeleteCommandType = SqlDataSourceCommandType.StoredProcedure; TemplateField tf1 = new TemplateField(); tf1.HeaderTemplate = new GridViewTemplate(DataControlRowType.Header, "Email" , "Email" , new Label()); tf1.ItemTemplate = new GridViewTemplate(DataControlRowType.DataRow, "Email" , "Email" , new Label()); / / tf1.EditItemTemplate = new GridViewTemplate(DataControlRowType.DataRow, "Email", "Email", new TextBox()); / / PRIMARY KEY TemplateField tf2 = new TemplateField(); tf2.HeaderTemplate = new GridViewTemplate DataControlRowType.Header, "Name" , "CompanyName" , new Label()); tf2.ItemTemplate = new GridViewTemplate(DataControlRowType.DataRow, "Name" , "CompanyName" , new Label
Height = Unit.Pixel(700); TemplateField tf = null; tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewTextTemplate("patientid", DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate("patientid", DataControlRowType.DataRow); gvDynamicArticle1.Columns.Add(tf); tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewTextTemplate("drugtradename", DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate("drugtradename", DataControlRowType.DataRow); gvDynamicArticle1.Columns.Add(tf); tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewTextTemplate("dosage DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate("dosage", DataControlRowType.DataRow); gvDynamicArticle1.Columns.Add(tf); tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewTextTemplate("frequency", DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate("frequency", DataControlRowType.DataRow); gvDynamicArticle1.Columns.Add(tf); tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewTextTemplate("instruction", DataControlRowType.Header