ListBox获取选择的值

         DataRowView drv = (DataRowView)this.listBoxRepair.SelectedItem;

            if (drv != null)
            {
                string repairid = drv["id"].ToString();
                string sql = "select a.*,isnull(b.username,-1) as username,isnull(b.phone,-1) as phone from repair a left join admin b on a.maintenanceman = b.id where a.id = " + repairid;
                DataTable dt = DBUtil.getData(sql);

                tbRepairDetails.Clear();

                tbRepairDetails.Text += "故障标题:" + dt.Rows[0]["title"].ToString() + "\r\n\r\n";
                tbRepairDetails.Text += "故障标题:" + dt.Rows[0]["content"].ToString() + "\r\n\r\n";
                // tbRepairDetails.Text += "提交时间:" + dt.Rows[0]["repairtime"].ToString() + "\r\n\rn";

                if (dt.Rows[0]["username"].ToString() == "-1")
                {
                    tbRepairDetails.Text += "维修员:暂未调派";

                }
                else
                {
                    tbRepairDetails.Text += "维修员:" + dt.Rows[0]["username"].ToString() + "\r\n\r\n";
                }

你可能感兴趣的:(C#)