Monday, April 28, 2014

Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.

Hello Sir ,

            When i submitted Save button in ASP.Net front end VB.net ,and back end Sql server , output displayed Error :
 

Both DataSource and DataSourceID are defined on 'GridView1'.   Remove one definition.<b></b>   please sent me full solution of this Error ASAP reply me.







Solution 





From: http://jibrankhan.wordpress.com/2008/06/18/both-datasource-and-datasourceid-are-defined-on-gridview1-remove-one-definition-bind-multiple-datasources-to-a-gridview-control/[^]
 
Remove one definition.
 
OK, so this is the message that you get most of the times when you try to bind your gridview or any other bindable controls, to multiple DataSources.
 
It happens most of the times when you bind your GridView control to an ObjectDataSouce or SqlDataSource on the design surface and then you try to bind the same GridView in code behind using the manual coding and sometimes it becomes necessary to do so in the scenarios of searching and manual paging etc.
 
(Binding to ObjectDataSource)
 
ObjectDataSource Binding
 
(Binding to manual DataSource)
 
GridView1.DataSource = null;
GridView1.DataSource = myDataTable;
GridView1.DataBind();
 
This is not going to solve the problem, the simples workaround is to set the DataSourceID to null.
 
GridView1.DataSourceID = null;
GridView1.DataSource = dt;
GridView1.DataBind();
 
now this is going to work perfectly fine but DataGrid required a page developer to write custom code to handle simple operations such as paging, sorting, editing or deleting data, the GridView control can automatically handle these operations provided its bound data source control supports these capabilities and we know that this kind of custom binding will kill any chances to automate your GridView to handle all these operations automatically.
 
Simplest way to resolve this issue is to display your required data to the client and then bind back the GridView to your original datasouce by setting the DataSourceID to null again. That will bring back all your automation functionality back to the GridView.
 
Cheers -

Sunday, April 6, 2014

How to Avoid white space /   int textbox?

Actually what i'm doing is I'm displaying the Values in Gridview in Another web page.

when I take the value  from cells to textbox if the value is null or empty the  &nbsp  show in textbox
 lbl_GUID.Text = grdrow.Cells[1].Text;
            text_name.Text = grdrow.Cells[2].Text;
            text_age.Text = grdrow.Cells[3].Text;

solution :
when u r taking data from gridview cell this problem will coem pl. try like this:
 lbl_GUID.Text = grdrow.Cells[1].Text.Replace(" ","&nbsp ")

MS in Computer Science with paid training in USA company