本文整理汇总了C#中DataTable.Select方法的典型用法代码示例。如果您正苦于以下问题:C# DataTable.Select方法的具体用法?C# DataTable.Select怎么用?C# DataTable.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTable
的用法示例。
在下文中一共展示了DataTable.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindTree
//邦定根节点
private void BindTree(string TargetFrame, DataTable dt)
{
//菜单状态
string MenuExpanded = ConfigHelper.GetConfigString("MenuExpanded");
bool menuExpand = bool.Parse(MenuExpanded);
DataRow[] drs;
if (this.ParentId != 0)
{
drs = dt.Select("nodeId=" + this.ParentId.ToString(), "orderId");
menuExpand = true;
}
else
{
drs = dt.Select("parentId=0", "orderId");// 选出所有根节点
}
//treeview set
this.TreeView1.Nodes.Clear();
this.TreeView1.Font.Name = "宋体";
this.TreeView1.Font.Size = FontUnit.Parse("9");
foreach (DataRow row in drs)
{
string nodeId = row["nodeId"].ToString();
string nodeNm = row["nodeNm"].ToString();
string url = row["url"].ToString();
string imageurl = row["imageUrl"].ToString();
string itemNo = row["itemNo"].ToString();
//为页面传递项目属性
if (url != string.Empty)
{
if (url.IndexOf("http://") == -1)
{
if (url.IndexOf('?') == -1)
{
url += "?itemNo=" + itemNo + "&pTypeNo=main";
}
else
{
url += "&itemNo=" + itemNo + "&pTypeNo=main";
}
}
}
TreeNode rootNode = new TreeNode();
rootNode.Text = nodeNm;
rootNode.Value = nodeId;
rootNode.NavigateUrl = url;
rootNode.Target = TargetFrame;
rootNode.Expanded = menuExpand;
rootNode.ImageUrl = imageurl;
rootNode.SelectAction = TreeNodeSelectAction.Expand;//和ASP.NET1.1中TREEVIEW的SelectExpands属性等效
this.TreeView1.Nodes.Add(rootNode);
this.CreateNode(TargetFrame, int.Parse(nodeId), rootNode, dt);
}
}
示例2: MenuleriDoldur
protected void MenuleriDoldur(DataTable DTMenu, StringBuilder SBMenu, DataRow[] DRC)
{
if (DRC.Length < 1)
return;
int sorguNo = Convert.ToInt32(DRC[0]["SorguNo"]);
if (DRC[0]["UstId"] == DBNull.Value)
SBMenu.Append("<ul data-snlg='menu'>");
else
SBMenu.Append("<ul>");
for (int i = 0; i < DRC.Length; i++)
{
DataRow[] drSubs = DTMenu.Select("UstId = " + DRC[i]["ID"].ToString() + " AND SorguNo = " + sorguNo.ToString(), "Sira");
if (drSubs.Length < 1)
{//eğer sorguNoya ait kayıt kalmadıysa bi sornakine geçebilmek için
sorguNo++;
drSubs = DTMenu.Select("UstId = " + DRC[i]["ID"].ToString() + " AND SorguNo = " + sorguNo.ToString(), "Sira");
}
SBMenu.Append("<li>");
if (drSubs.Length > 0)
{
if (!string.IsNullOrEmpty(DRC[i]["Resim"].ToString()))
SBMenu.AppendFormat("<img src=\"{0}\"/>", DRC[i]["Resim"].ToString());
SBMenu.AppendFormat("<a href=\"javascript:;\">{0}</a><i class='fa fa-angle-right'></i>", DRC[i]["KtgAd"].ToString());
}
else
{
string link = "javascript:;";
if (DRC[i]["SeoUrl"].ToString().Contains("http") || DRC[i]["SeoUrl"].ToString().Contains("//"))
link = DRC[i]["SeoUrl"].ToString();
else if (string.IsNullOrEmpty(DRC[i]["SeoUrl"].ToString().Replace("#", "")))
link = "javascript:;";
else
link = string.Format("/{0}/{1}/{2}", Snlg_ConfigValues.s_Dil, Snlg_ConfigValues.GetUrlValueByKey("project"), DRC[i]["SeoUrl"].ToString() + Snlg_ConfigValues.urlExtension);
if (!string.IsNullOrEmpty(DRC[i]["Resim"].ToString()))
SBMenu.AppendFormat("<img src=\"{0}\"/>", DRC[i]["Resim"].ToString());
SBMenu.AppendFormat("<a href=\"{0}\">", link);
SBMenu.AppendFormat("{0}</a>", DRC[i]["KtgAd"].ToString());
}
MenuleriDoldur(DTMenu, SBMenu, drSubs);
SBMenu.Append("</li>");
}
SBMenu.Append("</ul>");
return;
}
示例3: GetSortedSchemaRows
internal static DbSchemaRow[] GetSortedSchemaRows(DataTable dataTable, bool returnProviderSpecificTypes)
{
DataColumn sortindex = dataTable.Columns[SchemaMappingUnsortedIndex];
if (null == sortindex)
{
sortindex = new DataColumn(SchemaMappingUnsortedIndex, typeof(int));
dataTable.Columns.Add(sortindex);
}
int count = dataTable.Rows.Count;
for (int i = 0; i < count; ++i)
{
dataTable.Rows[i][sortindex] = i;
};
DbSchemaTable schemaTable = new DbSchemaTable(dataTable, returnProviderSpecificTypes);
const DataViewRowState rowStates = DataViewRowState.Unchanged | DataViewRowState.Added | DataViewRowState.ModifiedCurrent;
DataRow[] dataRows = dataTable.Select(null, "ColumnOrdinal ASC", rowStates);
Debug.Assert(null != dataRows, "GetSchemaRows: unexpected null dataRows");
DbSchemaRow[] schemaRows = new DbSchemaRow[dataRows.Length];
for (int i = 0; i < dataRows.Length; ++i)
{
schemaRows[i] = new DbSchemaRow(schemaTable, dataRows[i]);
}
return schemaRows;
}
示例4: SelectDistinct
/// <summary>
/// ���˵��ֶ��ظ�ֵ��������JSON��Ҫ���ַ������
/// </summary>
/// <param name="dataTable">��Ҫת����datatable</param>
/// <param name="fieldName">�ֶ�����</param>
/// <returns>{name:'value'},{name:'value'}</returns>
public static string SelectDistinct(DataTable dataTable, string fieldName)
{
StringBuilder sb = new StringBuilder();
int date=0;
if (fieldName.ToLower().IndexOf("date")>-1)
date = 1;
else
date = 0;
bool rc = false;
object lastValue = null;
foreach (DataRow dr in dataTable.Select("", fieldName))
{
if (lastValue == null || !(ColumnEqual(lastValue, dr[fieldName])))
{
lastValue = dr[fieldName];
if (lastValue != null)
{
if (rc)
sb.Append(",");
sb.Append("{name:'");
if (date==1)
sb.Append( Convert.ToDateTime(lastValue).ToShortDateString());
else
sb.Append(lastValue.ToString());
sb.Append("'}");
rc = true;
}
}
}
return sb.ToString();
}
示例5: AddNodes
// 用遞迴方式建立 Nodes
private void AddNodes(ref TreeNode pNode, ref DataTable dt_Al_List, int up_al_sid)
{
DataRow[] dRow = dt_Al_List.Select("up_al_sid = " + up_al_sid.ToString());
// 如果有資料,則建立子節點
if (dRow.GetUpperBound(0) > -1)
{
TreeNode subNode;
foreach (DataRow sRow in dRow)
{
subNode = new TreeNode();
if (sRow[0].ToString() == lb_al_sid.Text)
{
subNode.Select();
}
subNode.Text = sRow[2].ToString();
subNode.Value = sRow[0].ToString();
subNode.NavigateUrl = "3001.aspx?al_sid=" + sRow[0].ToString();
subNode.Target = "_parent";
subNode.ToolTip = sRow[3].ToString();
pNode.ChildNodes.Add(subNode);
AddNodes(ref subNode, ref dt_Al_List, int.Parse(sRow[0].ToString()));
}
dRow = null;
}
}
示例6: TestStringTrailingSpaceHandling
public void TestStringTrailingSpaceHandling()
{
DataTable dataTable = new DataTable("Person");
dataTable.Columns.Add("Name", typeof(string));
dataTable.Rows.Add(new object[] { "Mike " });
DataRow[] selectedRows = dataTable.Select("Name = 'Mike'");
Assert.Equal(1, selectedRows.Length);
}
示例7: btnEdit_Click
protected void btnEdit_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
try
{
ddcb_City.DataBind();
foreach (ListItem item in ddcb_City.Items)
{
item.Selected = false;
}
hdn_CityAdminId.Value = ((Button)sender).CommandArgument.ToString();
ddcb_City.DataBind();
DataTable dtCityAdmin = objAppAdmin.GetCityAdminInfo(Convert.ToInt32(hdn_CityAdminId.Value));
if (dtCityAdmin.Rows.Count > 0)
{
DataTable dtCities = new DataTable();
dtCities = objAppAdmin.GetCityAdminMapping(Convert.ToInt32(hdn_CityAdminId.Value));
foreach (ListItem item in ddcb_City.Items)
{
var x = from row in dtCities.Select()
where row["CityId"].ToString() == item.Value.ToString()
select row;
if (x.Count() > 0)
{
if (((DataRow)x.First())["CityId"].ToString() == item.Value.ToString())
item.Selected = true;
}
}
//ddl_City.SelectedValue = dtCityAdmin.Rows[0]["CityId"].ToString();
txtAddress.Text = dtCityAdmin.Rows[0]["Address"].ToString();
txtEmail.Text = dtCityAdmin.Rows[0]["Email"].ToString();
txt_FirstName.Text = dtCityAdmin.Rows[0]["FirstName"].ToString();
txt_LastName.Text = dtCityAdmin.Rows[0]["LastName"].ToString();
//txtConfirmPassword.Text = _dt.Rows[0]["Password"].ToString();
//txtPassword.Text = _dt.Rows[0]["Password"].ToString();
tr_password.Visible = false;
tr_Conpassword.Visible = false;
pnl_AddAdmin.Visible = true;
pnl_AdminList.Visible = false;
btn_Save.Text = "Aktualisiert";
rfvConfirmPassword.Enabled = false;
rfvPassword.Enabled = false;
}
}
catch (Exception ex)
{
//Helper.errorLog(ex, Server.MapPath(@"~/ImpTemp/Log.txt"));
}
}
}
示例8: GetColumnString
public static string GetColumnString(DataTable dt, string name, string defaultValue)
{
string val = defaultValue;
DataRow[] rows = dt.Select("Name = '" + name + "'");
if (rows.Length > 0) {
val = (string)rows[0]["Value"];
}
return val;
}
示例9: GetFilteredAnnouncementList
public static List<AnnouncementInfo> GetFilteredAnnouncementList(DateTime date, DataTable dt)
{
List<AnnouncementInfo> list = new List<AnnouncementInfo>();
DataRow[] filteredRows;
filteredRows = dt.Select("VisibleStartDate='" + date.Date + "'");
foreach (DataRow dr in filteredRows)
list.Add(dr.ToAnnouncementList());
return list;
}
示例10: GetNewDataTable
private DataTable GetNewDataTable(DataTable dt, string condition)
{
DataTable newdt = new DataTable();
newdt = dt.Clone();
DataRow[] dr = dt.Select(condition);
for (int i = 0; i < dr.Length; i++)
newdt.ImportRow((DataRow)dr[i]);
return newdt;
}
示例11: DataTableFilter
public static DataTable DataTableFilter(DataTable dtin, string query)
{
if (query == string.Empty) return dtin; // se não existir nada para fazer baza...
DataTable dtout = dtin.Clone();
foreach (DataRow row in dtin.Select(query))
dtout.ImportRow(row);
return dtout;
}
示例12: GetColumnBool
public static bool GetColumnBool(DataTable dt, string name, bool defaultValue)
{
bool val = defaultValue;
DataRow[] rows = dt.Select("Name = '" + name + "'");
if (rows.Length > 0) {
bool success = false;
val = Boolean.TryParse((string)rows[0]["Value"], out success);
if (!success)
val = defaultValue;
}
return val;
}
示例13: LoadDetailQuarter
private void LoadDetailQuarter()
{
string OrderNo = Request.QueryString["no"].ToString();
dtDetail = SellPlanBus.GetOrderDetail(OrderNo);
DataRow[] rows = dtDetail.Select("ParentID = 0");//赛选父节点为0的行
foreach (DataRow row in rows)//循环每节点里的子节点
{
LoadQuarter(row);
}
}
示例14: GetChildren
public static CostCentre[] GetChildren(DataTable dt, string query)
{
DataRow[] foundRows = dt.Select(query);
CostCentre[] children = new CostCentre[foundRows.Length];
for (int i = 0; i < foundRows.Length; i++)
{
CostCentre cc = CostCentreDB.Load(foundRows[i]);
cc.Children = GetChildren(dt, "parent_id = " + cc.CostCentreID.ToString());
children[i] = cc;
}
return children;
}
示例15: BindModuleTree
private void BindModuleTree(TreeNodeCollection TNC, string SuperID, DataTable dtMenu)
{
if (dtMenu != null && !string.IsNullOrEmpty(SuperID))
{
DataTable dt_menusuper = null;
if (Session["ActiveModule"] != null)
{
dt_menusuper = TreeTableBLL.GetAllSuperNodeIDs("MCS_SYS.dbo.Right_Module", "SuperID", "ID", Session["ActiveModule"].ToString());
}
foreach (DataRow _row in dtMenu.Select("SuperID=" + SuperID))
{
TreeNode tn = new TreeNode();
tn.Text = "<span style=font-size:14px;>" + _row["Name"].ToString() + "</span>";
tn.Value = _row["ID"].ToString();
tn.ToolTip = _row["Name"].ToString();
if (SuperID == "1")
{
tn.Text = "<div style='font-size:14px; background-color:#CCCCCC; width:140px;height:24px;line-height:24px;'>" + _row["Name"].ToString() + "</div>";
}
if (dt_menusuper != null && dt_menusuper.Select("SuperID=" + tn.Value).Length > 0)
{
tn.ExpandAll();
}
if (dtMenu.Select("SuperID=" + tn.Value).Length == 0)
{
tn.NavigateUrl = "~/SubModule/switch.aspx?Action=1&Module=" + tn.Value;
tn.Target = "_top";
}
else
{
tn.NavigateUrl = "#";
//tn.Target = "_top";
}
TNC.Add(tn);
BindModuleTree(tn.ChildNodes, _row["ID"].ToString(), dtMenu);
}
}
}