Click here to Skip to main content
15,359,217 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a web form.Which consists 3 fields. From date, to Date, Seller Name. on click of submit button, data of all 3 fields should be displayed in RDLC report.. rightnow only the id of dropdown is displaying instaed of the name.. I am using a master called userinfo to get the details of seller.
I used
.Even this doesn't work.
Kindly help

What I have tried:

i have used this..
Updated 27-Jun-17 21:35pm

1 solution

It depends on what you want to fetch from the DropDown List...

This is to get the Text of the DropDown List:

string dropDownText = DropList.SelectedItem.Text.ToString();

This is to get the Value of the DropDown List:

string dropDownValue = DropList.SelectedValue.ToString();
Member 11933161 28-Jun-17 4:30am
Thanks for the reply.. I will tell my issue in deep.
I have written the following code in Reportviewer.aspx.cs page:
ViewState["FROM"] = Request["FROM"].ToString();
ViewState["TO"] = GetString(Request["TO"].ToString());

ViewState["SELLER"] =Request["SELLER"].ToString();

string fDate = ViewState["FROM"].ToString();
string toDate = ViewState["TO"].ToString();

int seller = int.Parse(ViewState["SELLER"].ToString()); //i am getting error here as "Input string was not in a correct format.".//

DateTime from = Convert.ToDateTime(fDate);
fDate = from.ToString("yyyy-MM-dd");

DateTime to = Convert.ToDateTime(toDate);
toDate = to.ToString("yyyy-MM-dd");

string lstrConn = System.Configuration.ConfigurationManager.ConnectionStrings["SQLConnString"].ToString();

SqlConnection conn = new SqlConnection(lstrConn);
string sql = "Select * FROM V_DemoRep ";

//if (seller > 0)
// sql = sql + " sellername " + seller;

SqlDataAdapter ad = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();

//ReportViewer2.ProcessingMode = ProcessingMode.Local;
////set path of the Local report
//ReportViewer2.LocalReport.ReportPath = Server.MapPath("~/rptVOrder.rdlc");

ReportDataSource rds = new ReportDataSource("DataSet1", ds.Tables[0]);
ReportViewer1.Width = Unit.Pixel(1200);
ReportViewer1.Height = Unit.Pixel(700);


& i have written code in tripreport.aspx.cs page:
private void pBindDDL()
DataTable dtFTLInfo = BuyerSellerTranAccept.GetBySeller(myUserInfo.Company.SlNo);

ddlSeller.DataSource = dtFTLInfo;
ddlSeller.DataValueField = "slno";
ddlSeller.DataTextField = "Name";

ddlSeller.Items.Insert(0, new ListItem("--Select--", "0"));
protected void Page_ResetButton(object sender, EventArgs e)
private void pClearControl()

txtFromDate.Text = "";
txtToDate.Text = "";

protected void Page_SubmitButton(object sender, EventArgs e)

// ViewReport(reportName, sSelectionFormula, sParameter, sFormula);
private void pShowReports()
if (myUserInfo == null) myUserInfo = (Model.Masters.SubscriberInfo)ViewState[USER_KEY];

StringBuilder sb = new StringBuilder();

// sb.Append("'../Registers.aspx')");
sb.Append("'TripStatusViewer.aspx?FROM=" + txtFromDate.Text + "&TO=" + txtToDate.Text + "&SELLER=" + ddlSeller.SelectedItem.Text.ToString() +"')");
// sb.Append("'../Registers.aspx?ID=" + reportName + "')");
//+ "&SELFORMULA=" + sSelectionFormula + "&PARAMETER=" + sParameter + "&FORMULA=" + sFormula + "')");

if (!Page.ClientScript.IsClientScriptBlockRegistered("report"))
ScriptManager.RegisterStartupScript(btnSubmit, this.GetType(), "report", sb.ToString(), false);


Prifti Constantine 28-Jun-17 5:09am
I cannot understand the problem in this section of the code and what does it have to do with the drop down list that you mentioned above. Also i would reccomend using session object to store the date you want instead of ViewState. The only obvious error that i see here is that the parsing of ViewState["Seller"] fails to compile according your mentions.Can i have some clarification on what exactly does Request["Seller"] returns?
Prifti Constantine 28-Jun-17 5:16am
It came to me that Seller is apparently the value that you want to retrieve from a control in the aspx file and populate the Seller value in the stringbuilder with it. One problem would be that the value you get in the ViewState["Seller"] might be null or might not contail numerical or grammatical values.
Member 11933161 28-Jun-17 6:21am
Actually, there is a master called company. & seller is derived from that company master. I have a web page with seller drop down.. When i click that drop-down i can see the names of the seller companies. But when i submit, i can see only the SlNo of the sellers in the report.. I want to display the names of the sellers in the report.
Prifti Constantine 29-Jun-17 3:32am
My answer is still to user the
string dropDownText = DropList.SelectedItem.Text.ToString();

If the value you want to retrieve is inside the Text attribute of the dropDownList then the above example should work fine..
If the value you want to retrieve is inside the Value attribute of the dropDownList then
this is what you should use:
string dropDownValue = DropList.SelectedValue.ToString();

In each case you have to pay attention to which attribute of the dropDownList you have assigned the Value you want to get.

What i do not understand in your comment is what exactly is SINo of the sellers
Member 11933161 30-Jun-17 1:17am
Hello sir,
In the report that is generating, i have field called seller name.. I want to display the name of the seller. Ex-Abhi.. But right now it its displaying the SlNo of the seller that is stored in the db.. Ex-4.
I tried the code that u have sent
string dropDownText = DropList.SelectedItem.Text.ToString();. But still getting error at " int seller = int.Parse(ViewState["SELLER"].ToString());" as " Input string was not in a correct format."
Member 11933161 30-Jun-17 1:17am
Iam binding the seller names to dropdown from Company master
Prifti Constantine 30-Jun-17 5:24am
This might be because You are trying to Convert a value that is inside the ViewState["Seller"] to an integer while you are storing it in a string value... Either way... If the ViewState["Seller"] returns an integer Value then it will not be stored inside the String dropDownText youre assigning it, If the ViewState["Seller"] returns a string Value then if the output is not numercal then it will never be converted or even throw an error. I would reccomend debuging it , see what value it returns and assign it to the appropriate type. Another suggestion would be to put this Whole process into a Try-Catch Block so you can manage your exceptions. If you need any clarification , Feel free to ask anytime! :)
Member 11933161 30-Jun-17 6:04am
Thank you for the observation. I feel, i have problem with the views that i have created.
Prifti Constantine 30-Jun-17 6:05am
I could provide some help if i had some Code to watch! :)

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