这是我的CS下拉文件:
protected void BindDropDownList()
{
DataTable dt = new DataTable();
string connString = System.Configuration.ConfigurationManager.AppSettings["EyeProject"];
SqlConnection conn = new SqlConnection(connString);
try
{
conn.Open();
string sqlStatement = "SELECT FirstName FROM tbl_UserDetails";
SqlCommand sqlCmd = new SqlCommand(sqlStatement, conn);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
DropDownList1.DataSource =dt;
DropDownList1.DataTextField = "FirstName"; // the items to be displayed in the list items
DropDownList1.DataBind();
}
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "No Data Found To display in the DropDown List"; …
Run Code Online (Sandbox Code Playgroud) 我有一个字符串
"transform(23, 45)"
Run Code Online (Sandbox Code Playgroud)
从这个字符串我必须提取23和45,我做了
var xy = "transform(23,45)".Substring("transform(23,45)".indexOf('(') + 1).TrimEnd(')');
var num = xy.Split(',');
Run Code Online (Sandbox Code Playgroud)
我正在使用c#.在c#中有没有更好的方法呢?