hi all
the usual way to bid a gridview is to data soursce
is there a way to do the folowing , creat a data table from the gridview shown valus " currunt page "
thanks
Wops , this is the solution
http://forums.asp.net/thread/1362057.aspx
hi all
the usual way to bid a gridview is to data soursce
is there a way to do the folowing , creat a data table from the gridview shown valus " currunt page "
thanks
Wops , this is the solution
http://forums.asp.net/thread/1362057.aspx
I have a gridview and a dataset. When I start my application I see the results in my gridview. When I clic on edit and chanche some value and click on update it wil give me this error:
ObjectDataSource 'ObjectDataSourcePersoon' could not find a non-generic method 'Update' that has parameters: naam, tussenvoegsel, achternaam, adres, woonplaats, telefoonnummer, original_id, Original_naam, Original_tussenvoegsel, Original_achternaam, Original_adres, Original_woonplaats, Original_telefoonnummer.
Does someone know whats the problem??
Can we see your code for both the GridView and the ObjectDataSource on your ASPX page?
||| <asp:GridView ID="GridView3" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan"
BorderWidth="1px" CellPadding="2" DataKeyNames="id" DataSourceID="ObjectDataSourcePersoon"
ForeColor="Black" GridLines="None">
<FooterStyle BackColor="Tan" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" SortExpression="id" />
<asp:BoundField DataField="naam" HeaderText="naam" SortExpression="naam" />
<asp:BoundField DataField="tussenvoegsel" HeaderText="tussenvoegsel" SortExpression="tussenvoegsel" />
<asp:BoundField DataField="achternaam" HeaderText="achternaam" SortExpression="achternaam" />
<asp:BoundField DataField="adres" HeaderText="adres" SortExpression="adres" />
<asp:BoundField DataField="woonplaats" HeaderText="woonplaats" SortExpression="woonplaats" />
<asp:BoundField DataField="telefoonnummer" HeaderText="telefoonnummer" SortExpression="telefoonnummer" />
</Columns>
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSourcePersoon" runat="server" DeleteMethod="Delete"
InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="DataSetRoosterTableAdapters.PersoonTableAdapter" UpdateMethod="Update">
<DeleteParameters>
<asp:Parameter Name="Original_id" Type="Int32" />
<asp:Parameter Name="Original_naam" Type="String" />
<asp:Parameter Name="Original_tussenvoegsel" Type="String" />
<asp:Parameter Name="Original_achternaam" Type="String" />
<asp:Parameter Name="Original_adres" Type="String" />
<asp:Parameter Name="Original_woonplaats" Type="String" />
<asp:Parameter Name="Original_telefoonnummer" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="naam" Type="String" />
<asp:Parameter Name="tussenvoegsel" Type="String" />
<asp:Parameter Name="achternaam" Type="String" />
<asp:Parameter Name="adres" Type="String" />
<asp:Parameter Name="woonplaats" Type="String" />
<asp:Parameter Name="telefoonnummer" Type="String" />
<asp:Parameter Name="Original_id" Type="Int32" />
<asp:Parameter Name="Original_naam" Type="String" />
<asp:Parameter Name="Original_tussenvoegsel" Type="String" />
<asp:Parameter Name="Original_achternaam" Type="String" />
<asp:Parameter Name="Original_adres" Type="String" />
<asp:Parameter Name="Original_woonplaats" Type="String" />
<asp:Parameter Name="Original_telefoonnummer" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="naam" Type="String" />
<asp:Parameter Name="tussenvoegsel" Type="String" />
<asp:Parameter Name="achternaam" Type="String" />
<asp:Parameter Name="adres" Type="String" />
<asp:Parameter Name="woonplaats" Type="String" />
<asp:Parameter Name="telefoonnummer" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
khalidelmeknesi:
<UpdateParameters>
<asp:Parameter Name="naam" Type="String" />
<asp:Parameter Name="tussenvoegsel" Type="String" />
<asp:Parameter Name="achternaam" Type="String" />
<asp:Parameter Name="adres" Type="String" />
<asp:Parameter Name="woonplaats" Type="String" />
<asp:Parameter Name="telefoonnummer" Type="String" />
<asp:Parameter Name="Original_id" Type="Int32" />
<asp:Parameter Name="Original_naam" Type="String" />
<asp:Parameter Name="Original_tussenvoegsel" Type="String" />
<asp:Parameter Name="Original_achternaam" Type="String" />
<asp:Parameter Name="Original_adres" Type="String" />
<asp:Parameter Name="Original_woonplaats" Type="String" />
<asp:Parameter Name="Original_telefoonnummer" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
Look at your UpdateParameters above, if the signature of your Update method does not accept the "Original_" parameters, then remove them from the declaration. You should only have the Parameters needed for your Update method.
|||I have removed them in the deafault.aspx page en it gives me now this error:
|||
The "id" parameter should be sent instead of the "original_id" parameter. Remove
OldValuesParameterFormatString="original_{0}"
from your ObjectDataSource collection and see if this works. The whole idea, is that the Parameters sent match the signature of your business class method.
|||Ik have do it again..remove all parameters with the prefix:
This is the error:
En this is the asp code:
<asp:ObjectDataSource ID="ObjectDataSourceTester" runat="server" DeleteMethod="Delete"
InsertMethod="Insert" SelectMethod="GetData"
TypeName="DataSetRoosterTableAdapters.PersoonTableAdapter" UpdateMethod="Update">
<DeleteParameters>
<asp:Parameter Name="Original_id" Type="Int32" />
<asp:Parameter Name="Original_naam" Type="String" />
<asp:Parameter Name="Original_tussenvoegsel" Type="String" />
<asp:Parameter Name="Original_achternaam" Type="String" />
<asp:Parameter Name="Original_adres" Type="String" />
<asp:Parameter Name="Original_woonplaats" Type="String" />
<asp:Parameter Name="Original_telefoonnummer" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="naam" Type="String" />
<asp:Parameter Name="tussenvoegsel" Type="String" />
<asp:Parameter Name="achternaam" Type="String" />
<asp:Parameter Name="adres" Type="String" />
<asp:Parameter Name="woonplaats" Type="String" />
<asp:Parameter Name="telefoonnummer" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="naam" Type="String" />
<asp:Parameter Name="tussenvoegsel" Type="String" />
<asp:Parameter Name="achternaam" Type="String" />
<asp:Parameter Name="adres" Type="String" />
<asp:Parameter Name="woonplaats" Type="String" />
<asp:Parameter Name="telefoonnummer" Type="String" />
</InsertParameters>
</asp:ObjectDataSource
I dont know what the problem is!
Show us your Update method as well.
|||Here it is:
<UpdateCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>UPDATE [dbo].[Persoon] SET [naam] = @.naam, [tussenvoegsel] = @.tussenvoegsel, [achternaam] = @.achternaam, [adres] = @.adres, [woonplaats] = @.woonplaats, [telefoonnummer] = @.telefoonnummer WHERE (([id] = @.Original_id) AND ((@.IsNull_naam = 1 AND [naam] IS NULL) OR ([naam] = @.Original_naam)) AND ((@.IsNull_tussenvoegsel = 1 AND [tussenvoegsel] IS NULL) OR ([tussenvoegsel] = @.Original_tussenvoegsel)) AND ((@.IsNull_achternaam = 1 AND [achternaam] IS NULL) OR ([achternaam] = @.Original_achternaam)) AND ((@.IsNull_adres = 1 AND [adres] IS NULL) OR ([adres] = @.Original_adres)) AND ((@.IsNull_woonplaats = 1 AND [woonplaats] IS NULL) OR ([woonplaats] = @.Original_woonplaats)) AND ((@.IsNull_telefoonnummer = 1 AND [telefoonnummer] IS NULL) OR ([telefoonnummer] = @.Original_telefoonnummer)));
SELECT id, naam, tussenvoegsel, achternaam, adres, woonplaats, telefoonnummer FROM Persoon WHERE (id = @.id)</CommandText>
<Parameters>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.naam" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="naam" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.tussenvoegsel" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="tussenvoegsel" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.achternaam" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="achternaam" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.adres" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="adres" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.woonplaats" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="woonplaats" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.telefoonnummer" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="telefoonnummer" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@.Original_id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="id" SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@.IsNull_naam" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="naam" SourceColumnNullMapping="True" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.Original_naam" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="naam" SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@.IsNull_tussenvoegsel" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="tussenvoegsel" SourceColumnNullMapping="True" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.Original_tussenvoegsel" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="tussenvoegsel" SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@.IsNull_achternaam" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="achternaam" SourceColumnNullMapping="True" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.Original_achternaam" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="achternaam" SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@.IsNull_adres" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="adres" SourceColumnNullMapping="True" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.Original_adres" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="adres" SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@.IsNull_woonplaats" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="woonplaats" SourceColumnNullMapping="True" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.Original_woonplaats" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="woonplaats" SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@.IsNull_telefoonnummer" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="telefoonnummer" SourceColumnNullMapping="True" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@.Original_telefoonnummer" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="telefoonnummer" SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="id" ColumnName="id" DataSourceName="" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@.id" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="id" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand
And here is a picture of my dataset:
I've had this happen before. I'm assuming this is the Update method which was automatically generated by your TableAdapter. If so, I end up just adding my own Update method to the TableAdpater with the signature you want. Therefore, don't include any of the extra "Original_" Parameters.
|||I have made my own update and delete methods and now it works..Thank you for your good and fast support..
i don't know if this is the right forum for this question but here goes. I have created a gridview to display a list of records retrieved by a SQL query. Everytime I run it, I get the following error:
Object must implement IConvertible.
I thought it might have to do with the data I'm passing in the session string from the previous page. Here is that code:
ProtectedSub cmdSubmit_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles cmdSubmit.ClickSession.Add("Shift", shShift.SelectedItem)
Session.Add("Type", shType.SelectedItem)Session.Add("SelDate", OccDate.SelectedDate)
Response.Redirect("SelectIncRep.aspx")
Here is the code that is supposed to execute and display the data on page_init:
<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"DataKeyNames="RID"DataSourceID="SqlDataSource1"Width="1215px"BorderStyle="Groove"BorderWidth="4px">
<Columns>
<asp:BoundFieldDataField="RID"HeaderText="Record ID:"InsertVisible="False"ReadOnly="True"
SortExpression="RID"/>
<asp:BoundFieldDataField="Date"HeaderText="Date:"SortExpression="Date"/>
<asp:BoundFieldDataField="Shift_ID"HeaderText="Shift:"SortExpression="Shift_ID"/>
<asp:BoundFieldDataField="Xref_ID"HeaderText="Type Of Occurence:"SortExpression="Xref_ID"/>
<asp:BoundFieldDataField="Notes"HeaderText="Notes:"SortExpression="Notes"/>
</Columns>
</asp:GridView>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:PerfDataConnectionString %>"
SelectCommand="SELECT [RID], [Notes], [Date], [Shift_ID], [Xref_ID] FROM [Safety_data] WHERE (([Shift_ID] = @.Shift_ID) AND ([Xref_ID] = @.Xref_ID) AND ([Date] = @.Date))">
<SelectParameters>
<asp:SessionParameterName="Shift_ID"SessionField="Shift_ID"Type="Int32"/>
<asp:SessionParameterName="Xref_ID"SessionField="Type"Type="Int32"/>
<asp:SessionParameterName="Date"SessionField="Date"Type="DateTime"/>
</SelectParameters>
</asp:SqlDataSource>
What could be causing the issue?
|||Session.Add("Shift", shShift.SelectedItem)
BezerkRogue:
Session.Add("Type", shType.SelectedItem)
Session.Add("SelDate", OccDate.SelectedDate).....
<asp:SessionParameterName="Shift_ID"SessionField="Shift_ID"Type="Int32"/>
<asp:SessionParameterName="Xref_ID"SessionField="Type"Type="Int32"/>
<asp:SessionParameterName="Date"SessionField="Date"Type="DateTime"/>
Thanks. I made that correction but still get the same error. I dumped my temporary internet files to make sure I wasn't loading cached data. Could there be anything else I might have missed?
|||Did you already googled this error?
I found some results that all pointed in the same direction, which seams to be the case here also. You omitted the select type, so maybe this is the solution?
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:PerfDataConnectionString %>"
SelectCommand="SELECT [RID], [Notes], [Date], [Shift_ID], [Xref_ID] FROM [Safety_data] WHERE (([Shift_ID] = @.Shift_ID) AND ([Xref_ID] = @.Xref_ID) AND ([Date] = @.Date))"SelectType="Text">
|||I added the selectcommandtype line in and still get the same error. The stack trace is chinese to me so I have no idea what the problem is.
Exception Details:System.InvalidCastException: Object must implement IConvertible.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.[InvalidCastException: Object must implement IConvertible.] System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +2514354 System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +264 System.Web.UI.WebControls.Parameter.get_ParameterValue() +66 System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +254 System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +276 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +754 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70 System.Web.UI.WebControls.GridView.DataBind() +4 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69 System.Web.UI.Control.EnsureChildControls() +87 System.Web.UI.Control.PreRenderRecursiveInternal() +41 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
|||Ok, I found the variable that is being passed wrong and corrected it. I have verified that I am getting variables passed and have printed them on screen. I have also verified that I have records available for those variables, now I just get no data. Am I missing a binding somewhere?
<asp:gridviewrunat="server"ID="RecordView"AutoGenerateColumns="False"DataKeyNames="RID"DataSourceID="SqlDataSource1"Width="1134px"GridLines="Both"EnableViewState="true"Visible="true">
<Columns>
<asp:BoundFieldDataField="RID"HeaderText="RID"Visible="true"ReadOnly="True"
SortExpression="RID"/>
<asp:BoundFieldDataField="Notes"HeaderText="Notes"Visible="true"SortExpression="Notes"/>
</Columns>
</asp:gridview>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:PerfDataConnectionString %>"
SelectCommand="SELECT [RID], [Notes] FROM [Safety_data] WHERE (([Date] = @.Date) AND ([Shift_ID] = @.Shift_ID) AND ([Xref_ID] = @.Xref_ID))"SelectCommandType="Text">
<SelectParameters>
<asp:QueryStringParameterName="Date"QueryStringField="strSelDate"Type="DateTime"/>
<asp:QueryStringParameterName="Shift_ID"QueryStringField="strShiftPull"Type="Decimal"/>
<asp:QueryStringParameterName="Xref_ID"QueryStringField="strTypePull"Type="Decimal"/>
</SelectParameters>
</asp:SqlDataSource>
date and time diffs,sql server