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

问题描述

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

推荐答案

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



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

08-16 00:03