Hi All,

I am using a DropDownList with 4 static items namely Pending, Deffered, Settled and Rejected as they are static in actual use and won't change.

This DDL is placed in a template field of a DataGrid. The table which is used to fill the DataGrid contain a field namely TagStatus which contains the status of the customer as Pending, Deffered etc..

One requirement is that when the DataGrid shows the customer's data , the DropDowlList's selected value should be the one in the database while the DropDownList should also contain other static fields for updating the customer status.

So what i do is that after Populating the DataGrid from the table, i loop through the items of the DataGrid and set the SelectedValue Property of each DDL as follows

PHP Code:

private void btnSearch_Click(object senderSystem.EventArgs e)
{
    
string ProcName "GetClaimedBorrowers"//Stored Procedure Name
    
string ClaimNo txtClaimNo.Text.Trim();   // the Key used for filtering
    
DataAccess objData = new DataAccess();  //Class for Data Access
    
DataSet ClaimData = new DataSet();
    try
    {
        
objData.openConnection();
        
objData.ProcName ProcName
        
objData.CreateCommand();
        
objData.Parameters("@ClaimNo",SqlDbType.VarChar,25,ClaimNo);                    
        
objData.createAdapter().Fill(ClaimData);    
        
gridAdjustments.DataSource ClaimData.Tables[0];                
        
gridAdjustments.DataBind();            
                
        
AssignStatus(ClaimData); 
        
    }
    catch(
Exception ex)
    {
        
lblMessage.Text ex.Message
    }
    finally
    {
        
objData.CloseConnection();
        
objData.DisposeConnection();
        
ClaimData.Dispose(); 
    }
}


private 
void AssignStatus(DataSet dsCreditors)
{        
    
int rows dsCreditors.Tables[0].Rows.Count;     
    for(
int i 0rowsi++)
    {
        
DropDownList ddl gridAdjustments.Items[i].FindControl("ddlStatus") as DropDownList;                
        
ddl.SelectedValue dsCreditors.Tables[0].Rows[i]["TagStatus"].ToString().Trim();
    }
}

// As i told u that static members of the DDL are
//       
//           1.  Pending
//           2.  Settled
//           3.  Rejected
//           4.  Deffered  
//
//
// I Receive error as  "Specified argument was out of 
// the range of valid values. Parameter name: Settled"
//
// This errors occurs when the AssignStatus() function is executed
//
// 
so can u help me out of this problem...... and is there some other proper way to assign retrieved values to DDLs without looping htrough all items

Any help is greatly appeciated

TC