This is a migrated thread and some comments may be shown as answers.

selection out of range parameter name value error.

1 Answer 108 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tarang
Top achievements
Rank 1
Tarang asked on 18 Apr 2012, 03:44 PM
Hi ,
My page has the following feature.
when clicked on any grid on page A,it will take few values in form of query string and fetch records on Page B based one the search criteria in the query string.
Problem is I get the error during the dataBind of page load of Page B.

 

Here is my code of PAGE B
  
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
 gvSearchResults.EmptyDataText =  " ";
gvSearchResults.Columns[3].Visible = false;
gvSearchResults.Columns[4].Visible = false;
gvSearchResults.DataSource = null;
gvSearchResults.DataBind();
/** going to assume that the only mode passing in is search */
if (Request["mode"] != null)
{
if (Request[SearchConstants.PARM_BIZDT] != null)
{
string strDt = Request[SearchConstants.PARM_BIZDT];
try 
{
DateTime dt =
DateTime.ParseExact(strDt, SearchConstants.PARM_BIZDT_FORMAT, DateTimeFormatInfo.InvariantInfo);
StartDT.SelectedDate = dt;
EndDT.SelectedDate = dt;
}
catch (Exception ex)
{
log.Error(
"Unable to parse search parm session date", ex);
}
}
if (Request[SearchConstants.PARM_EXCHANGETYPE] != null)
ContractSelect.Exchange = Request[
SearchConstants.PARM_EXCHANGETYPE];//.Substring(0, 4); 
else 
ContractSelect.Exchange = "";
//if (Request[SearchConstants.PARM_COMMODITY] != null) 
//{ 
// string strCommodity = Request[SearchConstants.PARM_COMMODITY].ToString(); 
// ContractSelect.Commodity = strCommodity;//.Substring(0, 2); 
 //} 
//else 
// ContractSelect.Commodity = ""; 
if (Request[SearchConstants.PARM_YEAR] != null)
{
try 
{
if (Request[SearchConstants.PARM_YEAR].Length >= 4)
ContractSelect.SetYear = int.Parse(Request[SearchConstants.PARM_CONTRACT_YEAR]);
}
catch (Exception ex)
{ log.Error( "Invalid contract year passed in.", ex);
} }
else 
ContractSelect.SetYear = 0;
if (Request[SearchConstants.PARM_MONTH] != null)
{ try 
{ ContractSelect.SetMonth = 
int.Parse(Request[SearchConstants.PARM_MONTH]);
}
catch (Exception ex)
{log.Error( "Invalid contract month passed in.", ex);
}
}
else 
ContractSelect.SetMonth = 0;
if (Request[SearchConstants.PARM_NUM] != null)
{
string value=Request[SearchConstants.PARM_NUM];
try 
{
hidAccountNum.Value = value;
}
catch (Exception ex)
{cmbAccount.Items.Add(new RadComboBoxItem(value, value));
cmbAccount.SelectedValue = value;
}
}
string str = String.Format("setTimeout(\"{0}.ajaxRequest(\'SEARCH\')\", 250);", RadAjaxManager1.ClientID);
ClientScript.RegisterStartupScript(Page.GetType(),"StartSearch", str, true); }
else 
{
DateTime lastSession = service.GetLastTradeSession();
StartDT.SelectedDate = lastSession;
EndDT.SelectedDate = lastSession;
}
btnExportExcel.OnClientClick = 
string.Format(@"{0}.__doPostBack('{1}', '{2}'); return false;",
RadAjaxManager1.ClientID, btnExportExcel.UniqueID,
btnExportExcel.CommandArgument);
TypeSelect.TradeType = "";
DataBind();   //error is here.  
}

Please let me know if you require anything else to understand the issue.

Thanks,
Tarang

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Apr 2012, 06:40 PM
Hello Tarang,

//RadComboBox combo1 = new RadComboBox();
            if (combo1.FindItemByValue("value") != null)
            {
                combo1.FindItemByValue("value").Selected = true;
            }


Thanks,
Jayesh Goyani
Tags
ComboBox
Asked by
Tarang
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or