Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hello,
 
I'm trying to create two grid-views with the same functionality but the footer would be different I've copied and pasted the first grid view , changed the id for the second one and run it but the commandname worked for the first one but not for the second one ? why my second GridView is not taking commandnames for the created buttons ?
Note: My buttons are templatefield .
Posted 3-Oct-12 2:09am
Edited 31-Oct-12 3:18am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

I Found the error i added this sentence EnableEventValidation="False" to the page tag and it worked ! =D
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

First Grid Template Field :
 
<asp:templatefield xmlns:asp="#unknown">
                    <edititemtemplate>
                        <<asp:Button ID="Update" runat="server" CommandName="Update" Text="Update" />
   <<asp:Button ID="Cancel" runat="server" 
ommandName="Cancel" Text="Cancel" />
                    </edititemtemplate>
                    <itemtemplate>
                           <<asp:Button ID="Edit" runat="server" 
ommandName="Edit" Text="Edit" />
                    </itemtemplate>
                    <footertemplate>
                        <asp:button id="Insert" runat="server" commandname="Insert" text="Insert" />
                    </footertemplate>
                </asp:templatefield>
 
Second Grid Template Field:
 
<asp:templatefield xmlns:asp="#unknown">
                    <edititemtemplate>
                        <<asp:Button ID="UpdateS" runat="server" CommandName="Update" Text="Update" />
   <<asp:Button ID="CancelS" runat="server" 
ommandName="Cancel" Text="Cancel" />
                    </edititemtemplate>
                    <itemtemplate>
                           <<asp:Button ID="EditS" runat="server" 
ommandName="Edit" Text="Edit" />
                    </itemtemplate>
                    <footertemplate>
                        <asp:button id="Search" runat="server" commandname="Insert" text="Insert" />
                    </footertemplate>
                </asp:templatefield>
 
And all the other columsn are the same except my footer which is different in controls type but still has no code so the controls wont matter
 
my Load Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
''Do Connection and bring Data From Access DataBase 
GridView1.DataSourse = DataSet1
GridView1.DataBind()
GridView2.DataSourse = DataSet1
GridView2.DataBind()
End Sub
 
The rowEditing for the first Grid
 

Protected Sub GridView1_RowEditing(sender As Object, e As System.Wev.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
 

	GridView1.EditIndex = e.NewEditIndex
        GridView1.DataSourse = DataSet1
        GridView1.DataBind()
End Sub
 
 
The rowEditing for the Second Grid
Protected Sub GridView2_RowEditing(sender As Object, e As System.Wev.UI.WebControls.GridViewEditEventArgs) Handles GridView2.RowEditing
 

    GridView2.EditIndex = e.NewEditIndex
        GridView2.DataSourse = DataSet1
        GridView2.DataBind()
End Sub
I've solved the first problem so now it recognize the Edit Command but after that it wont see the other buttons command such as update or cancel .. i solved the first problem by binding the grid to the data at Page_load instead of a button click but now i need to bind at RowEditing level which makes a problem , what would be the problem ?
 
Note : Only one grid has to be shown at a time
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

what ever .cs code u wrote for first grid u should write for second grid .
like
 
protected void gv1_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
   {}
 protected void gv2_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
    {
}
  Permalink  
Comments
ayat abukhadra at 3-Oct-12 9:35am
   
I did the full code is different but still not working its not recognizing the second grid templateField buttons as they got commandnames I've tried to just show a msgbox on the row command function for the second grid but it didn't even enter that code
solanki.net at 3-Oct-12 23:54pm
   
can u send your code ?
ayat abukhadra at 4-Oct-12 2:43am
   
I'm gonna post it as a solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,189
1 Sergey Alexandrovich Kryukov 5,666
2 CPallini 4,810
3 George Jonsson 3,429
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100