Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# tigermain 10/22/2007 5:53 PM
I've been using the gridview control quite happily all day then I went to try my code and it has screwed. The only difference I had made was to put the gridview in a panel/placeholder (tested both).

I am using the DataKey property, filling it with user.id's and using a button column to pass the itemindex through via commandargument (standard feature of gridview). I then use this to pull back the user.id from the datakeys collection.

This works fine if I have it sat on an page in the admin however when i put the same gridview in side a panel or placeholder container control the datakeys always returns an empty collection for the datakeys property

Any ideas, it must be a cuyahoga thing as I have tested it completely in a test rig without cuyahoga. Here's some sample's of my code....
< asp:GridView ID="gvUserEntries" runat="server" OnRowCommand="gvUserEntries_RowCommand"
                    AutoGenerateColumns="false" DataKeyNames="Id" CssClass="tbl" UseAccessibleHeader="true">
                this.gvUserEntries.DataSource = userService.FindUsersByRole(Convert.ToInt32(this.ddlRoles.SelectedValue));
                this.gvUserEntries.DataBind();
        protected void gvUserEntries_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Response.Redirect("UserEdit.aspx?UserId=" + this.gvUserEntries.DataKeys[Convert.ToInt32(e.CommandArgument)].Value, true);
        }
# mgaerber 10/23/2007 9:56 AM
Hi,

where exactly did you put the grid? Is it an UserControl of a module you created?
It would be good to see the complete code behind (especially what happens in Page_Load)



# tigermain 10/23/2007 10:04 AM
The code is on a webform in the admin folder inheriting from AdminBasePage. There is nothing related to the gridview in the load event is is only populated on postback of a drop down list and viewstate is enabled

As I said it works perfectly as long as its not in a panel or placeholder

# Constructor 5/10/2009 12:49 AM
tigermainI've been using the gridview control quite happily all day then I went to try my code and it has screwed. The only difference I had made was to put the gridview in a panel/placeholder (tested both).

I am using the DataKey property, filling it with user.id's and using a button column to pass the itemindex through via commandargument (standard feature of gridview). I then use this to pull back the user.id from the datakeys collection.

This works fine if I have it sat on an page in the admin however when i put the same gridview in side a panel or placeholder container control the datakeys always returns an empty collection for the datakeys property

Any ideas, it must be a cuyahoga thing as I have tested it completely in a test rig without cuyahoga. Here's some sample's of my code....
< asp:GridView ID="gvUserEntries" runat="server" OnRowCommand="gvUserEntries_RowCommand"
                    AutoGenerateColumns="false" DataKeyNames="Id" CssClass="tbl" UseAccessibleHeader="true">
                this.gvUserEntries.DataSource = userService.FindUsersByRole(Convert.ToInt32(this.ddlRoles.SelectedValue));
                this.gvUserEntries.DataBind();
        protected void gvUserEntries_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Response.Redirect("UserEdit.aspx?UserId=" + this.gvUserEntries.DataKeys[Convert.ToInt32(e.CommandArgument)].Value, true);
        }

I have just had something very similar to this. onrowupdating event does not fire when GridView is inside a panel. This I found when finishing the LightBox Module which I will soon post. Very frustrating and lost me an hour or two in Google. Still do not understand why.