查询需要更新listview中的dropdownlist中的值。 然后dropdownlist的值应该使用c#,ASP.NET
填充数据库中的特定表protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
{
float TrSsb;
float AchSsb;
if (e.CommandName == "Update")
{
TextBox txtSysmoid = (TextBox)e.Item.FindControl("txtSysmoid");
DropDownList drpRegion = (DropDownList)e.Item.FindControl("drpRegion");
DropDownList drpMoName = (DropDownList)e.Item.FindControl("drpMoName");
TextBox txt1stWeekTar = (TextBox)e.Item.FindControl("txt1stWeekTar");
TextBox txt1stWeekAch = (TextBox)e.Item.FindControl("txt1stWeekAch");
TextBox txt2anWeekTar = (TextBox)e.Item.FindControl("txt2anWeekTar");
TextBox txt2anWeekAch = (TextBox)e.Item.FindControl("txt2anWeekAch");
TextBox txt3rdWeekTar = (TextBox)e.Item.FindControl("txt3rdWeekTar");
TextBox txt3rdWeekAch = (TextBox)e.Item.FindControl("txt3rdWeekAch");
TextBox txt4thWeekTar = (TextBox)e.Item.FindControl("txt4thWeekTar");
TextBox txt4thWeekAchv = (TextBox)e.Item.FindControl("txt4thWeekAchv");
Label lblTotlTar = (Label)e.Item.FindControl("lblTotlTar");
Label lblTotlAchv = (Label)e.Item.FindControl("lblTotlAchv");
float Trnumber1 = float.Parse(txt1stWeekTar.Text);
float Trnumber2 = float.Parse(txt2anWeekTar.Text);
float Trnumber3 = float.Parse(txt3rdWeekTar.Text);
float Trnumber4 = float.Parse(txt4thWeekTar.Text);
//float Trtotal = float.Parse(lblTotlTar.Text);
TrSsb = Trnumber1 + Trnumber2 + Trnumber3 + Trnumber4;
lblTotlTar.Text = TrSsb.ToString();
float Achnumber1 = float.Parse(txt1stWeekAch.Text);
float Achnumber2 = float.Parse(txt2anWeekAch.Text);
float Achnumber3 = float.Parse(txt3rdWeekAch.Text);
float Achnumber4 = float.Parse(txt4thWeekAchv.Text);
// float Achtotal = float.Parse(lblTotlAchv.Text);
AchSsb = Achnumber1 + Achnumber2 + Achnumber3 + Achnumber4;
lblTotlAchv.Text = AchSsb.ToString();
if (TrSsb >= AchSsb)
{
string updateCommand = "update om_DailyMoWiseCollection_Rpt set om_Region = '" + drpRegion.SelectedValue + "',om_Mo_Name = '" + drpMoName.SelectedValue + "',om_1stWeek_Target = '" + txt1stWeekTar.Text + "',om_1stWeek_Achv = '" + txt1stWeekAch.Text + "',om_2ndWeek_Target = '" + txt2anWeekTar.Text + "',om_2ndWeek_Achv = '" + txt2anWeekAch.Text + "',om_3rdWeek_Target ='" + txt3rdWeekTar.Text + "',om_3rdWeek_Achv ='" + txt3rdWeekAch.Text + "',om_4thWeek_Target ='" + txt4thWeekTar.Text + "',om_4thWeek_Achv ='" + txt4thWeekAchv.Text + "',om_total_Target ='" + lblTotlTar.Text + "',om_total_Achv ='" + lblTotlAchv.Text + "' Where om_sysmo_id = '" + txtSysmoid.Text + "'";
SqlDataSource1.UpdateCommand = updateCommand;
}
}
答案 0 :(得分:0)
我会考虑使用DataGridView。这些支持在单元格中执行下拉列表,并且具有更紧密的数据库集成。在UI设计器中添加列时,您可以选择为列类型指定DataGridComboBoxColumn。
我这样做的原因纯粹是简单和完成任务的速度。
要在列表视图中执行您想要的操作,需要测量感兴趣的子项目的位置等。当用户滚动一点时,这可能很棘手。