Click here to Skip to main content
15,891,905 members

how to send data into dropdown control using sendkey + C#

Maahi Sawarkar asked:

Open original thread
Hello
I m doing one windows application where i used web browser control,button for connecting URL, textbox for search data in my form. I navigate webbrowser control to one of the dataentry website. I have the data in my database like name, address city, dbo, district etc.
what i m doing i search data from database on name criteria and getting all values in dataset then using 'SendKey' i send that searched data to the particular fields of the website and it works also.The problem is that it works for the textbox control of the website but not for the dropdown control. I used the 'Tab' key for sending data.That website Using Dropdown Control for City,State,Country, Gender etc. Whenever i select some item from dropdown control it postback every time and load page every time. To avoid postbacking and reloading in website i try to make this application.

Below is My COde:
C#
private void fillData()
{
 //Code for searching the record against 'CustomerName'
         if (dSet.Tables[0].Rows[0]["DistrictName"] != DBNull.Value)         //Dropdown Control
         SendKeys.Send(dSet.Tables[0].Rows[0]["DistrictName"].ToString().Trim());
         WaitFor();
         SendKeys.Send("{TAB}");
         SendKeys.Send(dSet.Tables[0].Rows[0]["City"].ToString().Trim());
         WaitFor();
        SendKeys.Send("{TAB}");
        SendKeys.Send(dSet.Tables[0].Rows[0]["SpouseName"].ToString().Trim()); //Textbox Control
        WaitFor();
        // and So Many Fields..
       WaitFor();
       GC.Collect();
}

private void WaitFor()
        {
            for (int i = 0; i <= 5000; i++)
            {
                Application.DoEvents();
                Application.DoEvents();
                Application.DoEvents();
                Application.DoEvents();
                Application.DoEvents();
            }
        }

Plz help me out what i do for sending data in dropdown control.

Regards
Maahi
Tags: C# (C# 2.0)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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