查看下拉值 [英] view dropdown value

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

问题描述

 受保护的  void  drpClaimNumber_SelectedIndexChanged( int  claimId =  int  .Parse(drpClaimNumber.SelectedValue.ToString());
           cmd =  SqlCommand("  ,con1);
           cmd.CommandType = CommandType.StoredProcedure;
           cmd.Parameters.Add(" ,SqlDbType.VarChar).Value = ClaimId;
           con1.Open();
           cmd.Connection = con1;
           SqlDataAdapter ada =  SqlDataAdapter(cmd);
           ada.Fill(ds);
           {
               如果(ds.Tables [ 0 ].Rows.Count  >   0 )
               {

                   txtFirstName.Text = ds.Tables [ 0 ].行[ 0 ] [ 名字"].ToString();
                   txtLastName.Text = ds.Tables [ 0 ].行[ 0 ] [ 姓氏"].ToString();
                   txtAddress.Text = ds.Tables [ 0 ].行[ 0 ] [ 地址1"].ToString();
                   txtPolicyNumber.Text = ds.Tables [ 0 ].rows [ 0 ] [  policy_number"].ToString();
                   txtDateOfLoss.Text = ds.Tables [ 0 ].Rows [ 0 ] [  date_of_loss"].ToString();
                   txtAdditionalDetails.Text = ds.Tables [ 0 ].rows [ 0 ] [  additional_details"].ToString();

                   字符串 sel_policy = ds.Tables [ 0 ].行[ 0 ] [" ].ToString();
                     int  indx1 = drpPolicyType.Items.IndexOf(drpPolicyType.Items.FindByText(sel_policy));
                     drpPolicyType.SelectedIndex = indx1;



                         字符串 sel_claims = ds.Tables [ 0 ].行[ 0 ] [" ].ToString();
                          int  indx2 = drpClaimType.Items.IndexOf(drpClaimType.Items.FindByText(sel_claims));
                         drpClaimType.SelectedIndex = indx2;



              }

               con1.Close();
           }
       } 


请检查此代码.实际上以我的形式他们是2 drpdown
一个.政策类型
b.索赔类型

声明类型drpdown与策略类型有关.
现在我正在编辑零件.

当我选择任何索赔编号时,它会在各个文本框和下拉列表中显示所有详细信息.但是问题是当我选择任何索赔编号时,我无法查看我的表格中接受索赔类型drpdown"的每个字段.在保单类型drpdown中,我可以在选择无要求后查看顶部,但是我无法查看索赔类型drpdown说明.我选择了policytype drpdwn autopostback属性true.

请告诉我,如何根据所选的索赔编号查看索赔类型下拉列表.

:((:sigh::confused :: confused:

解决方案

string sel_claims = ds.Tables[0].Rows[0]["claims_description"].ToString();
                         int indx2 = drpClaimType.Items.IndexOf(drpClaimType.Items.FindByText(sel_claims));
                         drpClaimType.SelectedIndex = indx2;



在第一行上设置一个断点,并检查sel_claims变量中的值,确保该值在drpClaimType.Items列表中可用.我认为drpClaimType.Items.FindByText方法区分大小写.我再次为claim_type添加了存储过程....实际上是按照policy_typ填充的,但是当我想查看每条记录时却没有填充.....但是现在这个问题已经解决了:):-\


protected void drpClaimNumber_SelectedIndexChanged(object sender, EventArgs e)
       {
           int claimId = int.Parse(drpClaimNumber.SelectedValue.ToString());
           cmd = new SqlCommand("Edit_ClaimDetails", con1);
           cmd.CommandType = CommandType.StoredProcedure;
           cmd.Parameters.Add("@Claim_Id", SqlDbType.VarChar).Value = claimId;
           con1.Open();
           cmd.Connection = con1;
           SqlDataAdapter ada = new SqlDataAdapter(cmd);
           ada.Fill(ds);
           {
               if (ds.Tables[0].Rows.Count > 0)
               {

                   txtFirstName.Text = ds.Tables[0].Rows[0]["First_name"].ToString();
                   txtLastName.Text = ds.Tables[0].Rows[0]["Last_name"].ToString();
                   txtAddress.Text = ds.Tables[0].Rows[0]["Address1"].ToString();
                   txtPolicyNumber.Text = ds.Tables[0].Rows[0]["policy_number"].ToString();
                   txtDateOfLoss.Text = ds.Tables[0].Rows[0]["date_of_loss"].ToString();
                   txtAdditionalDetails.Text = ds.Tables[0].Rows[0]["additional_details"].ToString();

                   string sel_policy = ds.Tables[0].Rows[0]["policy_description"].ToString();
                    int indx1 = drpPolicyType.Items.IndexOf(drpPolicyType.Items.FindByText (sel_policy ));
                     drpPolicyType.SelectedIndex = indx1;



                         string sel_claims = ds.Tables[0].Rows[0]["claims_description"].ToString();
                         int indx2 = drpClaimType.Items.IndexOf(drpClaimType.Items.FindByText(sel_claims));
                         drpClaimType.SelectedIndex = indx2;



              }

               con1.Close();
           }
       }


please check this code . actually in my form their are 2 drpdown
a. policy type
b. claim type

claim type drpdown is related to policy type .
now i am working on editing part.

when i select any claim number than it shows all the details in various textboxes and dropdowns. but the problem is when i select any claim number than i am able to view every feild in my form accept in claim type drpdown. in policy type drpdown i can view on the top after selcting claim no but i am not able to view claim type drpdown description. i selected policytype drpdwn autopostback property true.

please tell me that how i can view in claim type dropdown also according to the selected claim no.

:(( :sigh: :confused::confused:

解决方案

string sel_claims = ds.Tables[0].Rows[0]["claims_description"].ToString();
                         int indx2 = drpClaimType.Items.IndexOf(drpClaimType.Items.FindByText(sel_claims));
                         drpClaimType.SelectedIndex = indx2;



set a break point on first line and check the value in the sel_claims variable, make sure this value is available in the drpClaimType.Items list. I think drpClaimType.Items.FindByText method is case sensitive.


now i have done....:) thnx for ur help. i added store procedure for claim_type again ....actualy it was filling according to policy_typ but it is not filling when i want to view every record..... but now this issue is solved :) :-\


这篇关于查看下拉值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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