可我只是点了连接字符串中Dbml.designer.cs在ConnectionString中app.conf?我写下了它成功指向的代码app.config.
public leDataContext() :
base(ConfigurationManager.ConnectionStrings["leConnString"].ToString(), mappingSource)
{
OnCreated();
}
Run Code Online (Sandbox Code Playgroud)
但是每当我修改或向dbml添加一个表时,它都会开始自动将该代码替换为此代码
public leDataContext() :
base("Data Source=.\\SQLEXPRESS;AttachDbFilename=\"D:\\My Projects\\App_Data\\le.mdf\";Integrated Security=True;Connect Timeout=30;User Instance=True", mappingSource)
{
OnCreated();
}
Run Code Online (Sandbox Code Playgroud)
我扩展了"连接"选项.将"应用程序设置"设置为False
如何在运行时更改CSS中的背景图像?我在身体中有以下背景图像,可以在运行时更改图像吗?
body {
height: 100%;
background: #fff8db url(../images/backgrounds/header-top.jpg) no-repeat center top;
/*background-color: #fff8db;*/
/*background-size: 1650px 900px;*/
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size:12px;
font-weight:normal;
color:#404040;
line-height:20px; }
Run Code Online (Sandbox Code Playgroud) 您好我可能知道如何获得下面的枚举值绑定到组合框?我写了下面的代码,但效果很好,但奇怪这是最好的方法.
public enum CourseStudentStatus
{
Active = 1,
Completed = 2,
TempStopped = 3,
Stopped = 4,
}
//Bind Course Status
Dictionary<string, int> list = new Dictionary<string, int>();
foreach (int enumValue in Enum.GetValues(typeof(CourseStudentStatus)))
list.Add(Enum.GetName(typeof(CourseStudentStatus), enumValue), enumValue);
var column = ((DataGridViewComboBoxColumn)dgv.Columns["studentCourseStatus"]);
column.DataPropertyName = "StudentStatus";
column.DisplayMember = "Key";
column.ValueMember = "Value";
column.DataSource= list.ToList();
Run Code Online (Sandbox Code Playgroud)
-----------------更新-------------------
我已根据Sanjeevakumar Hiremat将我的代码更改为此它完美地运作.
cbStatus.DataSource = Enum.GetValues(typeof(CourseStudentStatus));
但是,当我想要一个Get()并希望将值绑定回cbStatus时,它会抛出错误{"对象引用未设置为对象的实例."}
cbStatus.SelectedValue = Course.Status;.
cbStatus.Datasource不为空,绑定后有值 cbStatus.DataSource = Enum.GetValues(typeof(CourseStudentStatus));
请指教.
如何DataGridViewComboBoxColumn在运行时更改以下内容:
理由:
我这样做的原因是因为Enum我拥有Status{New=1,Stop=2,Temp=3}.当我想注册学生时,状态始终设置为New.所以当我保存时,它会自动保存Status = 1.
嗨我运行时将数据绑定到datagridview组合框.但是如何让它自动显示第一项呢?我无法从DataGridViewComboBoxColumn中找到selectedindex.
DataGridViewComboBoxColumn cbStudentCourse = (DataGridViewComboBoxColumn)dgStudentCourse.Columns["studentCourseStatus"];
cbStudentCourse.DataSource = Enum.GetValues(typeof(CourseStudentStatus));
cbStudentCourse.DisplayIndex = 1;
Run Code Online (Sandbox Code Playgroud)
- 更新---
我看到有人在解决方案中做这个3
LInk
你确定我需要这么长的代码来选择第一个项目??????
我的日期时间向我展示了我已经把它作为这个的秒数
TimeSlotFrom = Value.ToShortTimeString();
我只能从笔记本电脑上查看HH:mm.但是,当从客户端的PC上读取时,它会显示为HH:mm:ss.
它与我客户端电脑中使用的时间格式有关吗?我如何处理这个只是显示HH:mm?
我想创建一个包含键和值的新列表
List<object> r = new List<object>();
r.Add("apple");
r.Add("John");
return r;
Run Code Online (Sandbox Code Playgroud)
当你用Addwatch r时,你会看到
[1] = apple
[2] = John
Run Code Online (Sandbox Code Playgroud)
问题:如何使[1]和[2]成为新密钥?当我添加r时,我希望看到[1]被名称替换.如下:
Name = apple
TeacherName = John
Run Code Online (Sandbox Code Playgroud) 您好我可能知道如何使用linq选择"案例"条件?注释掉的代码是我的问题.我怎么把条件放在那里?我的代码:
var r = from u in Users
join p in Payments on u.Id equals p.UserId
join soi in SaleOrderItems on p.ReferenceId equals soi.Id
//if soi.InventoryTypeId == 1
//then join i in Inventories on soi.InventoryOrCourseId equals i.Id
//elseif soi.InventorytypeId ==2
//then join c in Courses on soi.InventoryOrCourseId equals c.Id
where u.Id == 5
select new{ u, p, soi, either i or c};
Run Code Online (Sandbox Code Playgroud) 如何使assemblyInfo.cs中的[assembly:AssemblyVersion("1.0.*")] for aboutbox与项目属性的发布版本类似?
目前似乎我必须输入两次..我参考了这个链接示例,我得到了预期的结果..
您好我刚刚升级到Framework 4.0并添加了关系外键到我的数据库.我想加入2表User and Staff并返回UI.员工表具有UserId.不得不说,每当在datagridview上点击用户名时,我想向所有文本框显示用户和员工数据.
我是用元组做的
public IEnumerable<Tuple<User, Staff>> Get()
{
using (qDataContext db = new qDataContext())
{
try
{
var r = from u in db.Users
join s in db.Staffs on u.Id equals s.UserId
select new Tuple<User, Staff>(u, s);
return r;
}
catch (Exception ex)
{
throw;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但在UI中,我该如何进行绑定?
gvUser.DataSource = user.Get();
仅供参考,gridview只显示用户名.员工表将存储密码,datejoined字段..
顺便说一句,我是否仍然需要连接表,因为我已经添加了表的外键引用..我在想它应该足够聪明地返回我User.Staff.Password
编辑
这是我发现..我已经将关系外键添加到我的数据库.当Staff.UserId指向UserId时,下面的代码已经能够返回User和Staff数据
And i don have to use the TUPLE to return those object :)!!
public IEnumerable<User> Get()
{
using (ZebraDataContext db …Run Code Online (Sandbox Code Playgroud) c# ×7
linq-to-sql ×3
linq ×2
winforms ×2
.net ×1
assemblies ×1
c#-4.0 ×1
css ×1
deployment ×1
gridview ×1
javascript ×1
list ×1