Click here to Skip to main content
15,888,181 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i am using dropdown list to select the value my dropdownloist binding is
C#
protected void Page_Load(object sender, EventArgs e)
      {
          if (!Page.IsPostBack)
          {
              Client_Combo();
}
          protected void Client_Combo()
        {
            Client objClient = new Client();
            drpClient.DataSource = objClient.GetGridValues();
            drpClient.DataValueField= "Id";
            drpClient.DataTextField = "Name";        
            drpClient.DataBind();           
        }
the saved value i am retrieving from table and assigning to DataTable  from that i want to assign dropdownlist for that i writen code like below
  BLL.Transaction objTrans = new BLL.Transaction();
            DataTable dtTrans = null;
            dtTrans = objTrans.GetTransactionValues(SelectedID);
            DTO.TransactionInfo TransInfo = new DTO.TransactionInfo();                 
            if (dtTrans.Rows[0]["Client"].ToString() != null)
            {
             drpClient.Items.FindByValue(dtTrans.Rows[0]["Client"].ToString()).Selected = true;
              
            } 

But drpClient.Items.FindByValue(dtTrans.Rows[0]["Client"].ToString() always coming null please help me.
Posted
Updated 6-Nov-13 4:47am
v2
Comments
ZurdoDev 6-Nov-13 10:03am    
What's the question?
From the code, it is clear that in value field of drpClient DropDown, you have Id.

I am not sure what dtTrans.Rows[0]["Client"].ToString() returns you?

Are you sure that it is the Id or is the Client Name.
As you are using FindByValue, so it will search by Id.

Let me know what you observe.
rk2krishna 7-Nov-13 6:43am    
dtTrans = objTrans.GetTransactionValues(SelectedID);
drTrans is a DataTable in that i have records from that i want to assign to dropdown thats y i given like that. it return Client Name that name only i need to assign dropdownlist
I understand that. But I am asking about the value of dtTrans.Rows[0]["Client"].ToString() while debugging. Please check and tell me.
rk2krishna 18-Nov-13 10:32am    
"sptex" string value

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