如何触发Gridview下拉列表选择的索引已更改 [英] How to fire Gridview dropdownlist selected index changed

查看:93
本文介绍了如何触发Gridview下拉列表选择的索引已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Gridview中有以下



两个下拉列表,

三个文本框。



当我选择下拉列表项时,



Gridview First文本框将更改值



例如,



在我的Gridview下拉列表中有Itemname



当我selectedChanged在下拉列表中,Gridview中的Rate TextBox显示文本框的速率。我给出了以下编码,但下拉列表获取空值,



In my Gridview has following

Two dropdown list,
Three TextBoxes.

When I Select the Dropdown list item,

The Gridview First textbox will be changed the value

For Example,

In my Gridview the Drop down list has Itemname

When I selectedChanged in the dropdownlist, The Rate TextBox in the Gridview display the rate of the textbox. I give the following coding, But the Dropdown list get null value,

protected void CMBItem_SelectedIndexChanged(object sender, EventArgs e)
   {
       DropDownList lb = (DropDownList)sender;
       GridViewRow gvRow = (GridViewRow)lb.NamingContainer;
         if (ViewState["CurrentTable"] != null)
       {
           DataTable dt = (DataTable)ViewState["CurrentTable"];
           string Iname = dt
           connect.cn();
           SqlCommand sqlcmd = new SqlCommand("Get_Item_PurchasePrice", connect.cn());
             sqlcmd.Parameters.AddWithValue("@ITEMCODE", lb.SelectedValue);
           sqlcmd.CommandType = CommandType.StoredProcedure;
           SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
           DataTable dt1 = new DataTable();
           da.Fill(dt1);
           if (dt1.Rows.Count > 0)
           {
               gvRow.Cells[4].Text = dt1.Rows[0][0].ToString();
               gvRow.Cells[5].Text = dt1.Rows[0][1].ToString();
           }
           //Store the current data in ViewState for future reference
           //ViewState["CurrentTable"] = dt;
           ////Re bind the GridView for the updated data
           //Gridview2.DataSource = dt;
           //Gridview2.DataBind();
       }
       //SetPreviousData();
   }







请帮我解决这个问题




Please help me for this problem

推荐答案

请尝试以下方法:

从GridView控件中提升DropDownList SelectedIndexChanged

DropDownList SelectedIndexChanged没有触发!


这篇关于如何触发Gridview下拉列表选择的索引已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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