Home > Net >  The radiobutton how to use c #!! consult
The radiobutton how to use c #!! consult

Time:09-27

Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. The Web;
Using System. Web. UI.
Using System. Web. UI. WebControls;
Using System. The Data;
Using System. The Data. SqlClient.
Using System. The Configuration;
The namespace SearsMarket
{
Public partial class frontpage2: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{

}

Protected void Button1_Click (object sender, EventArgs e)
{
If (RadioButton1. Checked==true)
{
String constring=ConfigurationManager. ConnectionStrings [r]. "cnnstring" ToString ();
SqlConnection myConnection=new SqlConnection (constring);
MyConnection. The Open ();
SqlCommand CMD=
New SqlCommand
(" the select goodsnm, goodspc from goods where goodsnm=@ xx ", myConnection);
CMD. The Parameters. AddWithValue (" @ "xx, TextBox1. Text);
CMD. ExecuteNonQuery ();
SqlDataReader br=CMD. ExecuteReader ();
GridView1. The DataSource=br;
GridView1. DataBind ();
MyConnection. Close ();
}

Else if (RadioButton2 Checked==true)
{

String constring=ConfigurationManager. ConnectionStrings [r]. "cnnstring" ToString ();
SqlConnection myConnection=new SqlConnection (constring);
MyConnection. The Open ();
SqlCommand CMD=
New SqlCommand
(" the select gkid, GKNM GKRNM, gktel from gk where gkid=@ aa ", myConnection);
CMD. The Parameters. AddWithValue (" aa "@, TextBox1. Text);
CMD. ExecuteNonQuery ();
SqlDataReader br=CMD. ExecuteReader ();
GridView1. The DataSource=br;
GridView1. DataBind ();
MyConnection. Close ();
}
Else if (RadioButton3 Checked==true)
{
String constring=ConfigurationManager. ConnectionStrings [r]. "cnnstring" ToString ();
SqlConnection myConnection=new SqlConnection (constring);
MyConnection. The Open ();
SqlCommand CMD=
New SqlCommand
(" select oderid oderdate, odercd from oders where oderdate=@ bb ", myConnection);
CMD. The Parameters. AddWithValue (" @ bb, "TextBox1. Text);
CMD. ExecuteNonQuery ();
SqlDataReader br=CMD. ExecuteReader ();
GridView1. The DataSource=br;
GridView1. DataBind ();
MyConnection. Close ();
}
The else
{
String constring=ConfigurationManager. ConnectionStrings [r]. "cnnstring" ToString ();
SqlConnection myConnection=new SqlConnection (constring);
MyConnection. The Open ();
SqlCommand CMD=
New SqlCommand
(" select lyid lynr, lytime from liuyan where lytime=@ bb ", myConnection);
CMD. The Parameters. AddWithValue (" @ bb, "TextBox1. Text);
CMD. ExecuteNonQuery ();
SqlDataReader br=CMD. ExecuteReader ();
GridView1. The DataSource=br;
GridView1. DataBind ();
MyConnection. Close ();
}


}


}

}
Code is to achieve the function of query results in different conditions can only last

CodePudding user response:

Because your parameter is a string, you should be converted to the corresponding type, such as gkid if it is a number, then you should put the textbox text into digital, then add into the parameter

CodePudding user response:

I leave a message by the date to find only the radiobutton can trigger other cannot, and I order also by date to find ah==

CodePudding user response:

https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.radiobutton? View=netframework 4.8

CodePudding user response:

The values of the three under your breakpoint
Because the button or SQL
  •  Tags:  
  • C#
  • Related