rafael.musco
-
12/3/2008 6:34:17 AM
RE:Problem with GridView
Hi Helena and thanks for your patience.... :-)
Let me try to be more detailed...
I have a register form. In this form, my clients must include their bank accounts. One client can have one or more bank accounts. After insert their bank accounts, they have to check wich one is the main account.
I'm using AJAX to do it more friendly for the user. I have a form with some fields as "bank number", "agency number", "account number", one gridview and two buttons as "insert account" and "send".
When a user fill the "bank number", "agency number", "account number" and click in "insert account" button, i get those fields information and create a new line in the GridView. The line in the GridView has the value of the fields "bank number", "agency number", "account number" and one more collumn that is the check box to set te main account.
As i told you, i'm using an UpdatePanel to do this friendly for the user. As far it is ok. No problems with this.
My problem is when i click in the "send" button. At this point, i have to read all the lines in the GridView and send it to a WebService. In the "send" button i'm doing the following lines...
if (grdAccounts.Rows.Count > 0) { foreach (GridViewRow r in grdAccounts.Rows) { .... } }
I have it as an UserControl. First i tried to use it with Kentico's UserControl WebPart. No problem. The GridView has all rows that was inserted.
To have it integrated with Kentico, i changed it to be a WebPart. As WebPart, i can insert some configuration properties that are usefull.
After doing it, the if condition is always false. Doesn't matter how many accounts i insert in the GridView, there is always 0 rows.
I don't know why, but it looks like when using WebPart, the GridView doesn't have a ViewState.
One important thing. The UserControl WebPart only worked after i changed the following code (i read it in the forum):
//public override void OnContentLoaded() //{ // base.OnContentLoaded(); // SetupControl(); //}
protected override void OnInit(EventArgs e) { base.OnInit(e); SetupControl(); }
I have already tried to put it in my WebPart either... I have already tried to set EnableViewState in WebPart, GridView, etc...
That is my problem...
Thanks again! Rafael
|