Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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:
Posted
Comments
GenJerDan 7-Dec-10 9:56am    
If ClaimID is an int, why are you converting it to a string, then back to an int. And if it's an int, why are you passing it to the SQL as a varchar?
Anyway, are you setting breeakpoints when running in debug mode to see what the value is during all this? Maybe you're not getting what you expect you're getting.

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.
 
Share this answer
 
Comments
goelhima 8-Dec-10 0:37am    
yes i checked this only :)
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 :) :-\
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900