Error : Does not have same signature as delegate
-
Hi, I have a datagrid in which I have a select command column on clicking of it I am try to bind a dataset with detail view but I am getting the following error The aspx code for it is <%@ Page Language="VB" AutoEventWireup="false" CodeFile="DG_Example.aspx.vb" Inherits="DG_Example" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Test Application</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="Generic_DG" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" DataKeyNames="ProdId" OnSelectedIndexChanged="Generic_DG_SelectedIndexChanged3"> <Columns> <asp:BoundField DataField="ProdName" HeaderText="Product" SortExpression="ProdName" > <HeaderStyle Font-Names="Arial" Font-Size="12px" /> <ItemStyle Font-Names="Arial" Font-Size="12px" /> </asp:BoundField> <asp:CommandField ShowEditButton="true" /> <asp:CommandField ShowSelectButton="true" /> </Columns> </asp:GridView> <br /> <br /> <asp:DetailsView ID="Generic_Det" runat="server" Height="50px" Width="125px" DataKeyNames="ProdId"> <Fields> <asp:BoundField DataField="ProdName" HeaderText="Product" SortExpression="ProdName" > <HeaderStyle Font-Names="Arial" Font-Size="12px" /> <ItemStyle Font-Names="Arial" Font-Size="12px" /> </asp:BoundField> <asp:CommandField ShowEditButton="True" /> </Fields> </asp:DetailsView> </div> </form> </body> </html> This is the code behind for it is as follows Imports System.Data Imports System Imports System.Data.SqlClient Imports System.Collections Imports System.ComponentModel Imports System.Drawing Imports System.Web Imports System.Web.SessionState Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Imports System.Data.OleDb Imports System.Configuration Partial Class DG_Example Inherits System.
-
Hi, I have a datagrid in which I have a select command column on clicking of it I am try to bind a dataset with detail view but I am getting the following error The aspx code for it is <%@ Page Language="VB" AutoEventWireup="false" CodeFile="DG_Example.aspx.vb" Inherits="DG_Example" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Test Application</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="Generic_DG" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" DataKeyNames="ProdId" OnSelectedIndexChanged="Generic_DG_SelectedIndexChanged3"> <Columns> <asp:BoundField DataField="ProdName" HeaderText="Product" SortExpression="ProdName" > <HeaderStyle Font-Names="Arial" Font-Size="12px" /> <ItemStyle Font-Names="Arial" Font-Size="12px" /> </asp:BoundField> <asp:CommandField ShowEditButton="true" /> <asp:CommandField ShowSelectButton="true" /> </Columns> </asp:GridView> <br /> <br /> <asp:DetailsView ID="Generic_Det" runat="server" Height="50px" Width="125px" DataKeyNames="ProdId"> <Fields> <asp:BoundField DataField="ProdName" HeaderText="Product" SortExpression="ProdName" > <HeaderStyle Font-Names="Arial" Font-Size="12px" /> <ItemStyle Font-Names="Arial" Font-Size="12px" /> </asp:BoundField> <asp:CommandField ShowEditButton="True" /> </Fields> </asp:DetailsView> </div> </form> </body> </html> This is the code behind for it is as follows Imports System.Data Imports System Imports System.Data.SqlClient Imports System.Collections Imports System.ComponentModel Imports System.Drawing Imports System.Web Imports System.Web.SessionState Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Imports System.Data.OleDb Imports System.Configuration Partial Class DG_Example Inherits System.
Rock Star. wrote:
Protected Sub Generic_DG_SelectedIndexChanged3(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
How did you created that function,Is it an automatically generated, Or User defined? Where you are calling this function? Because No control handle attached to it. The second argument 'e' must be a type of System.EventArgs
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
Rock Star. wrote:
Protected Sub Generic_DG_SelectedIndexChanged3(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
How did you created that function,Is it an automatically generated, Or User defined? Where you are calling this function? Because No control handle attached to it. The second argument 'e' must be a type of System.EventArgs
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
Its a user defined function and I am calling it on the selected index changed event of datagrid.
Rock Star
In Your aspx page u can see, in the GV code, Following line
OnSelectedIndexChanged="Generic_DG_SelectedIndexChanged3"
Delete it. The function that you created is already attached to GV that is the problem. And call this function inside the GV'sSelectedIndexChanged
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
In Your aspx page u can see, in the GV code, Following line
OnSelectedIndexChanged="Generic_DG_SelectedIndexChanged3"
Delete it. The function that you created is already attached to GV that is the problem. And call this function inside the GV'sSelectedIndexChanged
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
Hi, I did it what you have mentioned but by deleting it for understanding the flow I have kept a msgbox in the function but it is not calling the Generic_DG_SelectedIndexChanged3 function becauuse it is not showing that msgbox too. One more thing I didnt understood your last comment i.e "And call this function inside the GV's SelectedIndexChanged "
Rock Star
-
Hi, I did it what you have mentioned but by deleting it for understanding the flow I have kept a msgbox in the function but it is not calling the Generic_DG_SelectedIndexChanged3 function becauuse it is not showing that msgbox too. One more thing I didnt understood your last comment i.e "And call this function inside the GV's SelectedIndexChanged "
Rock Star
When you pass a
DataGridCommandEventArgs
to a function you can assign that function only to OnEditCommand,OnUpdateCommand,OnItemCommand etc... I dont think there is a command event forSelectedIndexChanged.
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
Hi, I did it what you have mentioned but by deleting it for understanding the flow I have kept a msgbox in the function but it is not calling the Generic_DG_SelectedIndexChanged3 function becauuse it is not showing that msgbox too. One more thing I didnt understood your last comment i.e "And call this function inside the GV's SelectedIndexChanged "
Rock Star
1.You can change your code that work with,
SelectedIndexChanged
of grid view. Dim index As Integer = Generic_DG.SelectedIndex cmd.Parameters.Add("@ProdId", SqlDbType.Int).Value = Generic_DG.DataKeys(index).Value.ToString()EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
When you pass a
DataGridCommandEventArgs
to a function you can assign that function only to OnEditCommand,OnUpdateCommand,OnItemCommand etc... I dont think there is a command event forSelectedIndexChanged.
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
1.You can change your code that work with,
SelectedIndexChanged
of grid view. Dim index As Integer = Generic_DG.SelectedIndex cmd.Parameters.Add("@ProdId", SqlDbType.Int).Value = Generic_DG.DataKeys(index).Value.ToString()EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
Thanx it is running now but i m getting error as {"Must declare the scalar variable "@ProdId"."} for the code adapt.Fill(DT_DS, "Test") How can I declase avariable @prodID as a scalar variable?
Rock Star
Change the following line.
cmd.CommandText = "select * from products where ProdID=@rodID"
Tocmd.CommandText = "select * from products where ProdID=" & Generic_DG.DataKeys(index).Value.ToString()
and delete the following line.cmd.Parameters.Add("@ProdId", SqlDbType.Int).Value = Generic_DG.DataKeys(e.Item.ItemIndex)
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
Change the following line.
cmd.CommandText = "select * from products where ProdID=@rodID"
Tocmd.CommandText = "select * from products where ProdID=" & Generic_DG.DataKeys(index).Value.ToString()
and delete the following line.cmd.Parameters.Add("@ProdId", SqlDbType.Int).Value = Generic_DG.DataKeys(e.Item.ItemIndex)
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
Hi, Thanx a lot for helping me and giving your precious time to solve this bug. I am trying few more things on it.
Rock Star
Good Luck :)
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
-
Good Luck :)
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
Hi, I am trying some more operation on the details view. But I am getting some problem in it is specified in the following link http://www.codeproject.com/script/Forums/View.aspx?fid=12076 with the subject line as "Edit the data in a detail view at run time [modified]"
Rock Star