Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
DataTable dtToGrid = (DataTable)Session["dtToGrid"];

 dtToGrid = select.SelectData(SefatyStockSelectSearch, ddl_Inv_IndentID.SelectedValue.ToString());
 GridView1.DataSource = dtToGrid;
 GridView1.DataBind();


this is binding gridview code
select.selectData is dll file it work on page load but i want to call text change event of dropdownlist

even though database has present record
and i want to show on every text change of dropdownlist
Posted
Updated 23-Sep-14 20:43pm
v2
Comments
Sergey Alexandrovich Kryukov 24-Sep-14 2:40am    
Not clear. Not even a question. What is the problem? There is no such notion, "call an event". What exactly do you want to achieve and why?
—SA
Sergey Alexandrovich Kryukov 24-Sep-14 2:44am    
Please don't re-post; this is considered as abuse.
—SA

1.You should not cache the data table used for your GridView inside the Session, because only some very important info should be cached there (like user ID). Note that in the case of GridView after data binding the data will be cached in the grid between post backs.

2.To filter the data in the grid view based on selection index changed of the drop down list you should set AutoPostBack="true" for your drop down list, then use the event OnSelectedIndexChanged. See details here.[^]

3.In generally in a grid view, if you have a big amount of data you have to use pagination. You could find details about this, and also about using GridView control in my next article: Advanced ASPX GridView Pagination and Data Entities[^]
 
Share this answer
 
Check Local IP Address [C#]
This example shows how to detect whether a host name or IP address belongs to local computer.
Get local computer name
Get local computer host name using static method Dns.GetHostName.
[C#]
string localComputerName = Dns.GetHostName();

Get local IP address list
Get list of computer IP addresses using static method Dns.GetHostAd¬dresses. To get list of local IP addresses pass local computer name as a parameter to the method.
[C#]
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());

Check whether an IP address is local
The following method checks if a given host name or IP address is local. First, it gets all IP addresses of the given host, then it gets all IP addresses of the local computer and finally it compares both lists. If any host IP equals to any of local IPs, the host is a local IP. It also checks whether the host is a loopback address (localhost / 127.0.0.1).
[C#]
public static bool IsLocalIpAddress(string host)
{
  try
  { // get host IP addresses
    IPAddress[] hostIPs = Dns.GetHostAddresses(host);
    // get local IP addresses
    IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());

    // test if any host IP equals to any local IP or to localhost
    foreach (IPAddress hostIP in hostIPs)
    {
      // is localhost
      if (IPAddress.IsLoopback(hostIP)) return true;
      // is local address
      foreach (IPAddress localIP in localIPs)
      {
        if (hostIP.Equals(localIP)) return true;
      }
    }
  }
  catch { }
  return false;
}

You can test the method for example like this:
[C#]
IsLocalIpAddress("localhost");        // true (loopback name)
IsLocalIpAddress("127.0.0.1");        // true (loopback IP)
IsLocalIpAddress("MyNotebook");       // true (my computer name)
IsLocalIpAddress("192.168.0.1");      // true (my IP)
IsLocalIpAddress("NonExistingName");  // false (non existing computer name)
IsLocalIpAddress("99.0.0.1");         // false (non existing IP in my net)

private string ReturnIPAddress() 
        {
            IPHostEntry host;
            string localIP = "?";
            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily == AddressFamily.InterNetwork)
                {
                    localIP = ip.ToString();
                }
            }
            return localIP;
        }
 
Share this answer
 
v2
Comments
[no name] 24-Sep-14 4:00am    
and this is not the answer for this question.
WHy have you posted this answer here

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900