C#混淆中的数据绑定. [英] Databinding in C# Confusion.
本文介绍了C#混淆中的数据绑定.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力理解数据绑定的概念,但这可能是因为我感到困惑.我无法弄清楚数据绑定是否已经超过我已经完成的工作.以下是连接到SQL数据库的代码片段.这是数据绑定吗?任何人都可以帮忙解释一下,然后再花几天的时间进行阅读.
谢谢
Hi,
I''m struggling to understand the concept of databinding, but it may be because i''m confusing myself. I cant work out if databinding is any more than what I''ve already done. Below is a snippet of my code connecting to my SQL database. Is this databinding? Can anyone help please explain before I spend several more days reading up on it.
Thanks
try
{
string UserIDSort = tbxUserID.Text.Remove(2, 6);
int UserIDInt = Convert.ToInt32(UserIDSort);
if (UserIDInt == 10 || UserIDInt == 15 || UserIDInt == 20)
{
SqlConnection connection = new SqlConnection("Data Source=OMEGA; Initial Catalog = Military; Integrated Security = True; Pooling = False");
connection.Open();
string s2 = "SELECT UserID, Password FROM [dbo].[Logon];";
SqlDataAdapter adapter = new SqlDataAdapter(s2, connection);
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter);
DataSet dataset = new DataSet();
adapter.Fill(dataset);
DataRow r = dataset.Tables[0].NewRow();
string un = (tbxUserID.Text);
string up = (tbxPassword.Text);
r["UserID"] = un;
r["Password"] = up;
dataset.Tables[0].Rows.Add(r);
adapter.Update(dataset);
dataset.AcceptChanges();
}
else
{
MessageBox.Show("Username Must Start with 10, 15 or 20 and must be 8 characters long");
}
}
推荐答案
数据绑定是在应用程序UI和业务逻辑之间建立连接的过程."
http://msdn.microsoft.com/en-us/library/ms752347 (v = VS.90).aspx [
"Data binding is the process that establishes a connection between the application UI and business logic."
http://msdn.microsoft.com/en-us/library/ms752347(v=VS.90).aspx[^]
In your snippet you have neither business logic nor a UI, ergo, this is not databinding.
This would be an example of databinding
DropDownList ddl = new DropDownList();
ddl.DataSource = myDatasource;
ddl.DataBind();
这篇关于C#混淆中的数据绑定.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文