请解决问题 [英] please solve the issue

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

问题描述

protected void Button1_Click1(object sender, EventArgs e)
 {for (int i = 0; i < GridView1.Rows.Count; i++)
     {
         CheckBox chkUpdate = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
         if (chkUpdate != null)
         {
             if (chkUpdate.Checked)
             {

                 
                 con.Open();
                 Label ID = (Label)GridView1.Rows[i].FindControl("Label7");
                 Session["ID1"] = ID.Text;
                 Label GatePassNo = (Label)GridView1.Rows[i].FindControl("Label1");

                 Label Customer_Name = (Label)GridView1.Rows[i].FindControl("Label2");

                 Label Customer_Location = (Label)GridView1.Rows[i].FindControl("Label3");

                 Label Product_Name = (Label)GridView1.Rows[i].FindControl("Label4");

                 Session["Asst"] = Product_Name.Text;
                 Label SerialNo = (Label)GridView1.Rows[i].FindControl("Label5");

                // con.Open();
               

                  
                             // con.Close();
                             //Button Add = (Button)PreviousPage.FindControl("Button2");
                             con.Close();

                             string qry = "insert into abc (Asset_Type,ID)values('"  + Product_Name.Text + "','" +ID.Text + "')";
                             SqlCommand comd = new SqlCommand(qry, con);
                             con.Open();
                         
                             comd.ExecuteNonQuery();
                             using (SqlCommand comm = new SqlCommand("select [Asset_Type] from abc where ID=@ID", con))
                             {

                                 // 2. define parameters used in command object
                                 SqlParameter para = null;
                                 para = new SqlParameter();
                                 para.ParameterName = "@ID";
                                 para.Value = ID.Text;
                                 comm.Parameters.Add(para);

                                 //Pass @Pages parameter

                                 SqlDataReader reade = comm.ExecuteReader();
                                 while (reade.Read())
                                 {
                                     Session["Asset_Type"] = Convert.ToString(reade["Asset_Type"]);
                                 }
}
}
public void bindddl()
{
    con.Open();
    string qry = " Select Vendor_Name from vendor where Asset_Type in ('"+Session["Asset_Type"]+"')";
        SqlDataAdapter adpt = new SqlDataAdapter(qry,con);
    DataTable dt = new DataTable();
    adpt.Fill(dt);
        DropDownList4.DataSource= dt;
    DropDownList4.DataBind();
    DropDownList4.DataTextField="Vendor_Name";
    DropDownList4.DataValueField="Vendor_Name";
    con.Close();
}



您好每一个都是我的代码。我的问题是如何从供应商中检索与gridview中所选资产相同的供应商名称。

供应商数据库包含


Hi Every one this is my code. My problem is how to retrieve the Vendor Name from vendor that are common to the assets selected in gridview.
Vendor database contains

Vendor_Name      Asset_Type
Futuresoft	Motherboard
Futuresoft	SMPS
Future India	HDD
Future India	joystick
Future India	Laptop Screen
Tech_M	        Baterry
Tech_M	        Laptop Screen
Tech_M	        Mouse
dgd	        Battery
ryy	        Battery
ryy	        HDD
ryy	        joystick
Religare	HDD
Religare	joystick
Religare	Mouse
Religare	Processor
Religare	RAM



如何在下拉列表中绑定所有资产类型共有的供应商名称。假设在gridview中我选择了三个资产,如硬盘和操纵杆以及笔记本电脑屏幕,那么下拉列表应包含Future India,因为该供应商包含三个资产。我将如何做到这一点请帮助


how will i bind the vendor names in drop down list that are common to all the Asset type. Suppose in gridview i selected three Assets such HDD and joystick and laptop screen then drop down list should contain Future India because this vendor contains three assets. How will i do this please help

推荐答案

只需将逗号(,)分隔的Asset_Type id字符串设为'1,2,3,4,5,6,7 ,8'并将其传递给程序。

制作一个商店程序,接受字符串中的Asset_Type id,如'1,2,3,4,5,6,7,8'。 br $>
Just make coma(,) separated string of Asset_Type id like '1,2,3,4,5,6,7,8' and pass it to the procedure.
Make one store procedure which accept the id of Asset_Type in string like '1,2,3,4,5,6,7,8'.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[SP_getAllVendorDetails]
(
	@Asset_TypeID varchar(max)
)
As
Begin
		EXEC(
'select distinct(Vendor_Name) FROM vendor  WHERE Asset_TypeID IN (' + @List + ')'
)
End





所以它将返回不同的供应商列表



so it will return distinct vendor list


首先创建一个函数,它将获取特定项目并返回供应商名称。

然后只需在选中或取消选中复选框时调用该函数。



要减少回发,您可以先选择复选框,然后选择其他复选框按钮单击获取所有选定的ceckbox项目的值,并将其传递给将返回供应商列表的函数。

将退货供应商列表投标到下拉列表。

你已经完成。
First create one function which will take particular items and return vendors name.
then just call the function when checkbox is checked or unchecked fromthe grid.

To reduce postback you can first make selection of checkboxes and then on another button click get the values of all selected ceckboxes items and pass it to the function which will return you the vendor list.
Bid the return vendor list to the drop down list.
you are done.


这篇关于请解决问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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