程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> 每次點擊按鈕後,判斷頁面是否已經有該行,沒有彈出repeater的一行,並給他賦一個這行附值,沒有則跳出,每次點擊repeater

每次點擊按鈕後,判斷頁面是否已經有該行,沒有彈出repeater的一行,並給他賦一個這行附值,沒有則跳出,每次點擊repeater

編輯:C#入門知識

每次點擊按鈕後,判斷頁面是否已經有該行,沒有彈出repeater的一行,並給他賦一個這行附值,沒有則跳出,每次點擊repeater


protected void btnAdd_click(object sender, EventArgs e)
{

try
{

//記錄第幾次追加
pressCount++;
typeString.Add(typeSelect.SelectedItem.ToString());
if (typeString.Count > 1)
{
for (int i = 0; i < typeString.Count - 1; i++)
{
if (typeString[typeString.Count - 1].Equals(typeString[i]))
{
string lastString = typeString[typeString.Count - 1];
typeString.Remove(lastString);
pressCount--;
return;
}
}
}
m_con = DataAccess.DbConn();

if (Session["sellerSave"].ToString().Trim().Equals("1"))
{
//是否選擇種別
if (typeSelect.SelectedValue.ToString().Equals("0"))
{
//提示選擇種別
ErrorHelp.alertMessageInAjax(Page, "S0100002");
}
else
{
DataTable tab_InfoResInfo = new DataTable();
tab_InfoResInfo.Columns.Add("type", typeof(string));
tab_InfoResInfo.Columns.Add("responsibleCD", typeof(string));
tab_InfoResInfo.Columns.Add("update_username", typeof(string));
tab_InfoResInfo.Columns.Add("update_date", typeof(string));
tab_InfoResInfo.Columns.Add("zipCode", typeof(string));
tab_InfoResInfo.Columns.Add("prefectures", typeof(string));
tab_InfoResInfo.Columns.Add("city", typeof(string));
tab_InfoResInfo.Columns.Add("detail1", typeof(string));
tab_InfoResInfo.Columns.Add("detail2", typeof(string));
tab_InfoResInfo.Columns.Add("email", typeof(string));
tab_InfoResInfo.Columns.Add("department", typeof(string));
tab_InfoResInfo.Columns.Add("title", typeof(string));
tab_InfoResInfo.Columns.Add("name", typeof(string));
tab_InfoResInfo.Columns.Add("tel", typeof(string));
tab_InfoResInfo.Columns.Add("mobile", typeof(string));
tab_InfoResInfo.Columns.Add("fax", typeof(string));
tab_InfoResInfo.Columns.Add("note", typeof(string));
for (int i = 0; i < pressCount; i++)
{

//添加行
DataRow dr = tab_InfoResInfo.NewRow();
tab_InfoResInfo.Rows.Add(dr);
}
//去重
distinct(typeString);
//list轉換成數據
string[] typeArray = typeString.ToArray();
for (int i = 0; i < typeArray.Length; i++)
{
tab_InfoResInfo.Rows[i][0] = typeArray[i];
}
// tab_InfoResInfo.Rows[pressCount - 1][0] = Session["repeater_type_string"].ToString().Trim();
sellersIndex_Repeater.DataSource = tab_InfoResInfo;
sellersIndex_Repeater.DataBind();
for (int i = 0; i < this.sellersIndex_Repeater.Items.Count; i++)
{
RepeaterItem resItem = sellersIndex_Repeater.Items[i];
TextBox repeater_responsibleCDTextBox = (TextBox)resItem.FindControl("repeater_responsibleCD");
repeater_responsibleCDTextBox.ReadOnly = true;
repeater_responsibleCDTextBox.Enabled = false;

}
// resSave.Style.Add("display", "block");
// resSave.Style.Add("display", "block");


}
}
else
{
//請先保存販売先情報
ErrorHelp.alertMessageInAjax(Page, "S0100038");
}


}
catch (MySqlException ex)
{
lbl_error.Text = ex.ToString();
LogControl.CmnOutPutLOG(Const.PageCodes.ProCategoryManage, Const.ErrorLevel.ERROR, ex.ToString());
}
catch (Exception ex)
{
lbl_error.Text = ex.ToString();
LogControl.CmnOutPutLOG(Const.PageCodes.ProCategoryManage, Const.ErrorLevel.ERROR, ex.ToString());

}
finally
{
DataAccess.DbClose(m_con);
}

 

}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved