Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
4
Answers
DataBind doesn't fire on GridView
Stanislav Godin
9y
1k
1
Reply
I have a very strange problem. I am developing the ASP.Net C# WebForm. I have a GridView with a sqldatasource and a textbox where I set a parameter from to the datasource. If I set the datasource on the GridVeiw itself, it works fine. I send a parameter and bind the GridView. I need to have a button and fire the DataBind() event from there. I had this scenario before and everything worked OK on other GridView's. So, I remove the datasource from the GridView and leave it with None, I put a button and placed my code there:
DetailsView1.DataSource = "GetRegisteredUser";
DetailsView1.DataBind();
When I hit the button, I am getting the message below. Just to clarify, the EmpID is my first column of the query.
DataBinding: 'System.Char' does not contain a property with the name 'EmpID'.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:
System.Web.HttpException: DataBinding: 'System.Char' does not contain a property with the name 'EmpID'.
Source Error:
Line 26: WebMsgBox.Show(TextBox1.Text); Line 27: DetailsView1.DataSource = "GetRegisteredUser";
Line 28: DetailsView1.DataBind();
Line 29: //} Line 30: }
Source File:
c:\Users\sgodin\Documents\Visual Studio 2010\WebSites\MaskFitAdmin\EHMaskSizeSet.aspx.cs
Line:
28
Stack Trace:
[HttpException (0x80004005): DataBinding: 'System.Char' does not contain a property with the name 'EmpID'.] System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +9805821 System.Web.UI.WebControls.DetailsView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +1444 System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +67 System.Web.UI.WebControls.DetailsView.PerformDataBinding(IEnumerable data) +12 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +123 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30 System.Web.UI.WebControls.DetailsView.DataBind() +4 EHMaskSizeSet.Button1_Click1(Object sender, EventArgs e) in c:\Users\sgodin\Documents\Visual Studio 2010\WebSites\MaskFitAdmin\EHMaskSizeSet.aspx.cs:28 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9752490 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +196 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
I set up a profiler and when I run my app,. nothing gets executed. That means the DataBind() doesn't fire. The GridView expects the data where the first row is EmpID and it is not there.
What is wrong happening here? As I said, I used that method before and everything worked just fine.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
Javascript Function Validation
asp.net validator that allows everything but not numbers