谁能告诉我我如何绑定2下拉菜单? [英] can anyone tell me that how i can bind 2 drop down ?

查看:67
本文介绍了谁能告诉我我如何绑定2下拉菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何绑定2个下拉菜单?

在我的项目中,有2个下拉列表.第一个是Policy类型,另一个是Claim类型....

当我在保单类型下拉列表中选择时,在索赔类型下拉列表中选择时,应该有与该保单类型相关的值,我在早期的Web表单中填写了这些值....

can anyone tell me that how i can bind 2 drop down ?

in my project there are 2 drop down... first is Policy type and another is Claim type....

when i select in policy type drop down then in claim type drop down there should be values related to that policy type which i filled in early web forms....

void Connection()
      {
          string strConnection = "Data Source=NSEZ-DD4-028;Initial Catalog=Insurance;Integrated Security= SSPI";
          SqlConnection objConnection = new SqlConnection(strConnection);
          try
          {

              objConnection.Open();
              SqlCommand command = new SqlCommand();


              command.CommandText = "Select Claim_Type_Id from Claim_Type where Policy_Type_Id =" + Convert.ToString(drpClaimType.Text);
              SqlDataReader reader = command.ExecuteReader();


              command.CommandText = "insert into Claims values ('" + txtSearchForCustomer.Text + "','" + Convert.ToString(txtPolicyNumber.Text) + "','" + txtDateOfLoss.Text + "','" + Convert.ToInt32(drpPolicyType.SelectedValue) + "','" + Convert.ToInt32(drpClaimType.SelectedValue) + "','" + txtAdditionalDetails.Text + "')";



              command.Connection = objConnection;
              command.ExecuteNonQuery();
              objConnection.Close();



          }
          catch (Exception e)
          {
              // Label8.Text = "";
              if (objConnection.State == ConnectionState.Open)
              {
                  objConnection.Close();
              }

          }
      }




现在要进行哪些更改...让我非常困惑...:(




now what changes are to be made...i m getting very confused... :(

推荐答案

您需要''级联下拉菜单''.只需使用google进行搜索,然后使用适合您情况的那个.
You need ''Cascading dropdown''. Just google for same and use the one that fits in your scenario.


它不在那里.
当我拖动它时,它不起作用.可以使用相同的下拉绑定吗?
It''s not coming there.
When I''m dragging it, its not working. Will it be possible with same drop down binding ?




首先将数据绑定到下拉列表策略类型,并在属性中将autopostback设置为true,然后在选定的策略更改索引中绑定
索赔类型.当您进行绑定和编写查询时,请使用-从Claim_Type中选择Claim_Type_Id,其中Policy_Type_Id ="+ drpClaimType.selectedvalue);

它可能会起作用...
如果您有任何疑问,请通知我...

问候,
Inayat Basha.
Hi,

first bind the data to dropdownlist policy type and in properties give autopostback to true, and in the selected index change of policy bind the
claim type. when ur binding and writing query use this --Select Claim_Type_Id from Claim_Type where Policy_Type_Id =" + drpClaimType.selectedvalue);

it may work...
if u have any doubt let me know...

Regards,
S.Inayat Basha.


这篇关于谁能告诉我我如何绑定2下拉菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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