要在选择ddl时更改列值 [英] want to change the column value on selection of ddl

查看:106
本文介绍了要在选择ddl时更改列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在gridview中有一个下拉列表控件,用于显示产品版本.我想要从dropdownlisst中选择版本时,价格表中的价格与之对应.

我的CS代码是


have a dropdownlist control in gridview which shows the product version . I want when i select the version from dropdownlisst the price corresponding to it from table comes in the price column .

my cs code is


private void BindProductData()
    {
      DataManager myData = new DataManager(DbFunctions.GetConnectionString());
      MySqlConnection myPConn = myData.GetPooledConnection(new MySqlConnection());
      DataSet productTable = new DataSet();
      MySqlDataAdapter sAdapter;

      sAdapter = new MySqlDataAdapter("select * from productmast P Inner join productdetail V on P.productid=V.productid Inner join userpermission U on P.productid=U.productid where adminuserid = " + Session["AdminUserId"].ToString() + "", myPConn);
      sAdapter.Fill(productTable, "productmast");
      if (productTable.Tables["productmast"].Rows.Count == 0)
      {
        LabelError.InnerText = "No Rows Found";
      }
      else
      {
        Products.DataSource = productTable;
      }
      Products.DataBind();
      myData.CloseConnection(myPConn);
    }

    protected void Products_RowDataBound(object sender, GridViewRowEventArgs e)
    {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
        DataManager myData = new DataManager(DbFunctions.GetConnectionString());
        MySqlConnection myPConn = myData.GetPooledConnection(new MySqlConnection());

        string strProductId = ((DataRowView)(e.Row.DataItem)).Row[0].ToString();

        //Setup the Select Checkbox

        CheckBox chkSelect = (CheckBox)e.Row.FindControl("chkSelect");
        if (chkSelect != null)
        {
          chkSelect.Checked = ShoppingCart.IsProductSelected((DataTable)Session["Admin_Order"], "productid", strProductId);
        }

        //Setup the Select Checkbox

        CheckBox chkEvalVersion = (CheckBox)e.Row.FindControl("ChkEvalVersion");
        if (chkEvalVersion != null)
        {
          chkEvalVersion.Checked = ShoppingCart.IsEvalVersion(Session["Admin_Order"], "productid", strProductId);
        }

        //Setup the version DropDownList
        DropDownList ddlVersion = (DropDownList)e.Row.FindControl("ddlVersion");

        if (ddlVersion != null)
        {
          MySqlDataReader productReader = null;
          myData.GetDataReader("productdetail", "productdetailid, version",
                   "productid = " + TextUtilities.ToSql(strProductId, "N"), null,
                   "productdetailid",
                   ref productReader, myPConn);

          ddlVersion.DataSource = productReader;
          ddlVersion.DataBind();
          ddlVersion.SelectedValue = ShoppingCart.GetSelectedProductDetailId((DataTable)Session["Admin_Order"], "productid", strProductId);
        }
        myData.CloseConnection(myPConn);
      }
    }

推荐答案

对于下拉列表控件,请检查是否添加了
For Drop down list control check u added
AutoPostBack = "true"

.

如果没有,则当您更改第一个下拉列表中的项目时,.aspx.cs页中的代码未命中.

or not.

If not the code in the .aspx.cs page is not hit when u change the item in the first drop down list.


这篇关于要在选择ddl时更改列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆