Gridview onRowupdating

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
10/24/2008 5:10:40 AM
Gravatar
Total Posts 3

Gridview onRowupdating

Hai all,

I am new on developing at Mojoportal and I try to create some custom feature and it works but why my gridview doesnt execute onrowupdating and this function cannot load.

I try utk set enableviewstate=true on that my usercontrol dan i tried too to change on web.config " DisablePageViewStateByDefault=true.

Please help me

 

10/24/2008 7:48:26 AM
Gravatar
Total Posts 18439

Re: Gridview onRowupdating

Hi,

In the future please post developer questions in the developer forum not the bug reporting forum.

Usually I hookup events myself in the OnInit like this:

this.grdPages.RowUpdating += new GridViewUpdateEventHandler(grdPages_RowUpdating);

Hope it helps,

Joe

10/24/2008 12:22:07 PM
Gravatar
Total Posts 3

Re: Gridview onRowupdating

Thanks Joe for this answer but i already follow your suggest but still gridview row updating cannot execute.

here is my code :

<asp:GridView ID="gridViewData" runat="server"
BorderWidth="0px" AutoGenerateColumns="False" Width="99%" CellPadding="2"
BorderColor="White" CaptionAlign="Top"
AllowPaging="True" PageSize="20" AllowSorting="True">
<EmptyDataTemplate>There is no data</EmptyDataTemplate>
<AlternatingRowStyle CssClass="ms-AlternatingRowStyle" />
<Columns >

<asp:TemplateField HeaderText="Action" ControlStyle-Width="55px" >
<ItemStyle />
<ItemTemplate>
<asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update"/>&nbsp;<asp:Button ID="btnDelete" runat="server" Text="Delete" CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="IdBank" Visible="false" >
<ItemStyle />
<ItemTemplate>
<asp:Label runat="server" id="lblIdCat" text='<%# Bind("IdBank") %>' />
</ItemTemplate>

</asp:TemplateField>

<asp:BoundField HeaderText="Code" DataField="Code" SortExpression="Code" >
<ItemStyle CssClass="ms-underline" HorizontalAlign="Left" />
<HeaderStyle CssClass="ms-underline" HorizontalAlign="Left" Font-Bold="true" />
</asp:BoundField>
<asp:BoundField HeaderText="Name" DataField="Name" SortExpression="Name" >
<ItemStyle CssClass="ms-underline" HorizontalAlign="Left" />
<HeaderStyle CssClass="ms-underline" HorizontalAlign="Left" Font-Bold="true" />
</asp:BoundField>
<asp:BoundField HeaderText="Created By" DataField="User_Created" SortExpression="User_Created" >
<ItemStyle CssClass="ms-underline" HorizontalAlign="Left" />
<HeaderStyle CssClass="ms-underline" HorizontalAlign="Left" Font-Bold="true" />
</asp:BoundField>
<asp:BoundField HeaderText="Created Date" DataField="Date_Created" SortExpression="Date_Created" >
<ItemStyle CssClass="ms-underline" HorizontalAlign="Left" />
<HeaderStyle CssClass="ms-underline" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Modified By" DataField="User_Modified" SortExpression="User_Modified" >
<ItemStyle CssClass="ms-underline" HorizontalAlign="Left" />
<HeaderStyle CssClass="ms-underline" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Modified Date" DataField="Date_Modified" SortExpression="Date_Modified" >
<ItemStyle CssClass="ms-underline" HorizontalAlign="Left" />
<HeaderStyle CssClass="ms-underline" HorizontalAlign="Left" />
</asp:BoundField>

</Columns>
</asp:GridView>

 

code behind :

protected override void OnInit(EventArgs e)
{
this.gridViewData.RowUpdating += new GridViewUpdateEventHandler(gridViewData_Updating);
}

protected void Page_Load(object sender, EventArgs e)
{
SiteUtils.AllowOnlyAuthenticated();
siteUser = SiteUtils.GetCurrentSiteUser();
Page.EnableViewState = true;

}

protected void gridViewData_Updating(object sender, GridViewUpdateEventArgs e)
{
try
{
Label lbl = (Label)gridViewData.Rows[e.RowIndex].FindControl("lblIdCat");
}
}

 

I can debug on my gridViewData_Updating code, so i think this procedure doesn't fire.

 

10/24/2008 12:28:55 PM
Gravatar
Total Posts 18439

Re: Gridview onRowupdating

Is that the complete code? I don't see where you are populating the grid in the first place.

If you are populating it from page load be sure and wrap (if!Page.IsPostBack) around the code that populates it. Page load fires on every request including postback and it will fire before the grid event. So if its binding the grid again on postback it will lose the edit item index and maybe it can't fire the event after that.

If its inside module I would also wrap the grid inside an UpDatePanel

Hope it helps,

Joe

10/24/2008 1:56:07 PM
Gravatar
Total Posts 3

Re: Gridview onRowupdating

what a silly of me.

With this my reply to you i always smile because i forgot to update my aspx to set enableviewstate=true,  i am only set my usercontrol.

Thanks Joe for your appreciate to me to help me. Your are the best. I hope you still want to help me if i am have error.

You must sign in to post in the forums. This thread is closed to new posts.