DataBinding: 'System.Char' does not contain a property with the name
16,811
The problem is that you bind a string to your DataSource
ddlEmployee.DataSource = DSEmployee.Tables[0].DefaultView.ToString();
And a string don't have a property APPRAISER_ID
.
select employee_id,appraiser_id from kirti_pms_reporting where appraiser_id='" +
varAppraiserId.ToString() + "'";
Is not a good idea because you could run into SqlInjection.
Related videos on Youtube
Author by
itzArun
Updated on June 04, 2022Comments
-
itzArun almost 2 years
I searched throughout the website for the error
I am getting this error while binding a dropdown list.
DataBinding: 'System.Char' does not contain a property with the name "APPRAISER_ID"
Here's my code:
DataSet DSEmployee = new DataSet(); DSEmployee = ws_service.GetReportingDtl(user); ddlEmployee.DataTextField = "APPRAISER_ID"; ddlEmployee.DataValueField = "APPRAISER_ID"; ddlEmployee.DataSource = DSEmployee.Tables[0].DefaultView.ToString(); ddlEmployee.DataBind();
And in my webservice.
string strQ = "select employee_id,appraiser_id from kirti_pms_reporting where appraiser_id='" + varAppraiserId.ToString() + "'";
My Inline code for dropdown list is
<asp:DropDownList ID="ddlEmployee" runat="server" AutoPostBack="true" CssClass="vlu">
What I missed here? The same code works fine in another aspx page.
-
SLaks over 12 yearsYou have a SQL injection vulnerability.
-
-
Hans Kesting over 12 yearsNote: the reason for the 'System.Char' error message is that the datasource should be Enumerable. That String is enumerable: it's a list of chars. And a Char doesn't have that 'Appraiser_id'.
-
dknaack over 12 years@HansKesting A String is not just a list of chars, or array of chars, in .NET.
-
Hans Kesting over 12 years@dknaack - no, a string is not a list of chars, but it is an
IEnumerable<Char>
, which is what counts here. -
dknaack over 12 years@HansKesting Yes
System.String
implementsIEnumerable<char>
, but other interfaces too. right -
SearchForKnowledge over 9 yearsCan you please help...stackoverflow.com/questions/28075489/…