c# button click event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doll
    New Member
    • Jul 2007
    • 24

    c# button click event

    hi
    i'm doing a program in c# asp.net..i have to retrievee some data from database and display in a grid..and then there is a textbox where i've to enter the reg no of a vehicle..once i enter the no and click the button the speed and ignition of the vehicle must be displayed in the other two text boxes..the first part i 've completed that is till retrieving data..i need the code for the button click event..please help....

    my code so far

    protected void Page_Load(objec t sender, EventArgs e)
    {
    GridCon.Open();
    SqlDataAdapter MyDa = new SqlDataAdapter( "select REGISTRATIONNO, UNIT_NO,SPEED,G PS_DATETIME,LAT ITUDE from GPSDATA where datediff(mi,gps data.GPS_DATETI ME,getdate())<3 0", GridCon);
    DataSet MyDs1 = new DataSet();
    MyDa.FillSchema (MyDs1, SchemaType.Sour ce, "gpsdata");
    MyDa.Fill(MyDs1 .Tables["gpsdata"]);
    DataTable MyDT = new DataTable();
    GridView1.DataS ource = MyDs1;
    GridView1.DataB ind();

    }

    protected void Button1_Click(o bject sender, EventArgs e)
    {
    //i need code for this
    }

    thanking you
  • Sasi Rekha
    New Member
    • Aug 2007
    • 18

    #2
    Originally posted by doll
    hi
    i'm doing a program in c# asp.net..i have to retrievee some data from database and display in a grid..and then there is a textbox where i've to enter the reg no of a vehicle..once i enter the no and click the button the speed and ignition of the vehicle must be displayed in the other two text boxes..the first part i 've completed that is till retrieving data..i need the code for the button click event..please help....

    my code so far

    protected void Page_Load(objec t sender, EventArgs e)
    {
    GridCon.Open();
    SqlDataAdapter MyDa = new SqlDataAdapter( "select REGISTRATIONNO, UNIT_NO,SPEED,G PS_DATETIME,LAT ITUDE from GPSDATA where datediff(mi,gps data.GPS_DATETI ME,getdate())<3 0", GridCon);
    DataSet MyDs1 = new DataSet();
    MyDa.FillSchema (MyDs1, SchemaType.Sour ce, "gpsdata");
    MyDa.Fill(MyDs1 .Tables["gpsdata"]);
    DataTable MyDT = new DataTable();
    GridView1.DataS ource = MyDs1;
    GridView1.DataB ind();

    }

    protected void Button1_Click(o bject sender, EventArgs e)
    {
    //i need code for this
    }

    thanking you
    hi,
    try this
    for (int i=0;i<gridview1 .rows.count;i++ )
    {
    if(textbox1.tex t==gridview1.ro ws[i]["REGISTRATIONNO "].tostring())
    {
    textbox2.text=g ridview1.rows[i]["SPEED"].tostring();
    textbox3.text=g ridview.rows[i]["the column name for ignition"].tostring();
    }
    }

    Comment

    Working...