且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我想在下拉列表中选定索引更改的下拉列表中选择的项目中,在gridview中显示该项目

更新时间:2022-12-02 15:26:09



根据您所提出的问题,我理解的是,您希望根据下拉列表中的值显示数据.如果正确,那么下面的代码可能对您有用,

您可以创建一个StoredProcedure,它可以接受输入作为下拉列表的值.

Hi,

From your encypted question what i understand is, you want to show your data depending on the value in the dropdownlist. If it is correct then below code may work for you,

You can create one StoredProcedure that can accept inputs as the value of your dropdownlist.

CREATE PROCEDURE selectDataByDDLValue(@ddlValue INTEGER)
AS
IF @ddlValue == 1
BEGIN
-- Query3 to execute
END
ELSE
BEGIN
  IF @ddlValue == 2
  BEGIN
  -- Query2 to execute
  END
  ELSE
  BEGIN
  -- Query3 to execute
  END
END
GO


希望您能想到.


Hope you got the idea.


CREATE PROCEDURE selectDataByDDLValue(@ddlValue INTEGER)
AS
IF @ddlValue == 1
BEGIN
-- Query3 to execute
END
ELSE
BEGIN
  IF @ddlValue == 2
  BEGIN
  -- Query2 to execute
  END
  ELSE
  BEGIN
  -- Query3 to execute
  END
END
GO


如果您要根据更改的下拉列表索引将数据与网格绑定,则应尝试使用此
if u want to bind data with grid according to dropdown selected index changed then u should try this
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  {
// get selected value of dropdown.
      int intValue= int.Parse(ddlCompany.SelectedValue.ToString());
// call function for displaying records in grid according to dropdown value 
      fnShowDetails(intValue);
  }

protected void fnShowDetails(int intReference)
  {
       // here u should send value(intReference) to database for getting record and bind the grid with returning  datatable or dataset .
  }



希望这对你有帮助.
谢谢



Hope this will help u.
Thanks