473,320 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Web Form do not update data when I click in update button

My web applicatin has two web forms using Master Page that access data tables in SqlServer database:

1 - Autoridade.aspx that shows data and search them

2- Autoridade_Atualizar.aspx that updates data in table lideranca

Autoridade.aspx has a GridView that show data and uses asp:HyperLinkField to redirect to Autoridade_Atualizar.aspx:

Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="gwDados" runat="server" AutoGenerateColumns="False" EmptyDataText="Não Existem Autoridades Cadastradas..."> <Columns> <asp:BoundField DataField="id" HeaderText="ID" /> <asp:BoundField DataField="nome" HeaderText="Nome" /> <asp:BoundField DataField="partido" HeaderText="Partido" /> <asp:BoundField DataField="aliado" HeaderText="Aliado" /> <asp:BoundField DataField="cargo" HeaderText="Cargo" /> <asp:BoundField DataField="lotacao" HeaderText="Lotação" /> <asp:BoundField DataField="atuacao" HeaderText="Atuação" /> <asp:HyperLinkField DataNavigateUrlFormatString="Autoridade_Atualizar. aspx?id={0}" Text="Editar" DataNavigateUrlFields="id" /> </Columns> </asp:GridView>
When I exchange the values of the DropDownLists fields and click on Update Button of the Form do not alter the data on gridview.

Expand|Select|Wrap|Line Numbers
  1. asp:Panel runat="server" ID="pnlUpdate" Visible="true"> <h1>Atualizar Autoridade</h1> <ul> <li> <asp:Label ID="CodAutoridade" runat="server" Text="Cód. Autoridade"></asp:Label> <asp:TextBox ID="tbCodAutoridade" Text="2013" Enabled="false" CssClass="radiusInput disable" runat="server" Width="546px"></asp:TextBox> </li> <li> <asp:Label Text="Nome" ID="label1" runat="server" Width="88px"></asp:Label> <asp:TextBox ID="tbNome" Text="" CssClass="radiusInput" runat="server" Width="654px" Height="16px"></asp:TextBox> </li> <li> <asp:Label ID="Cargo" runat="server" Text="Cargo"></asp:Label> <asp:DropDownList ID="ddlcargo" DataTextField="carg_cargo" DataValueField="carg_cd_cargo" CssClass="radiusInput" runat="server" Width="454px"></asp:DropDownList> </li> <li> <asp:Label ID="Partido" runat="server" Text="Partido"></asp:Label> <asp:DropDownList ID="ddlpartido" DataTextField="part_sigla" DataValueField="part_cd_partido" CssClass="radiusInput" runat="server" Width="254px"></asp:DropDownList> </li> <li>
Expand|Select|Wrap|Line Numbers
  1. protected void bntAtualizar_Click(object sender, EventArgs e)
  2. {
  3. this.OnUpdate();
  4. }
  5.  
  6. private void OnUpdate()
  7. {
  8.  
  9. mdc = new ModelDataContext();
  10. try
  11. {
  12. lid_lideranca lideranca = mdc.lid_liderancas.First(aut => aut.lid_cd_lideranca == int.Parse(tbCodAutoridade.Text.Trim()));
  13.  
  14.  
  15. tbNome.Text = lideranca.lid_nome;
  16. ddlcargo.SelectedIndex = ddlcargo.Items.IndexOf(ddlcargo.Items.FindByText(l ideranca.lid_cd_partido.ToString()));
  17. ddlpartido.SelectedIndex = ddlpartido.Items.IndexOf(ddlpartido.Items.FindByTe xt(lideranca.lid_cd_partido.ToString()));
  18. tbDescricao.Text = lideranca.lid_cargo2;
  19. tbemail.Text = lideranca.lid_email;
  20. tbfacebook.Text = lideranca.lid_facebook;
  21. tbtwitter.Text = lideranca.lid_twitter;
  22. tbendercomercial.Text = lideranca.lid_endereco_comercial;
  23. tbenderesidencial.Text = lideranca.lid_endereco_residencial;
  24. tbfonecelular.Text = lideranca.lid_fone_celular;
  25. tbfoneresidencial.Text = lideranca.lid_fone_residencial;
  26. tbfonecomercial.Text = lideranca.lid_fone_comercial;
  27. ddlmunicipio.SelectedIndex = ddlmunicipio.Items.IndexOf(ddlmunicipio.Items.Find ByText(lideranca.lid_cd_cidade_atuacao.ToString()) );
  28. ddlbasealiada.SelectedIndex = ddlbasealiada.Items.IndexOf(ddlbasealiada.Items.Fi ndByText(lideranca.lid_cd_base_aliada.ToString())) ;
  29. ddlorgao.SelectedIndex = ddlorgao.Items.IndexOf(ddlorgao.Items.FindByText(l ideranca.lid_cd_orgao.ToString()));
  30.  
  31. mdc.SubmitChanges();
  32. Response.Redirect("Autoridade.aspx");
  33. }
  34. catch (Exception)
  35. {
  36.  
  37. }
  38. finally
  39. {
  40. mdc.Dispose();
  41. }
  42.  
  43. }
Apr 30 '14 #1
1 1569
you have simply debug the application step by step using the "F10" key and in between you can get the issue area. best of luck.

kumar
Apr 30 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: msnews.microsoft.com | last post by:
Hello! I'm Jim by asp How can show "abc" in textbox when click one botton?
5
by: Matt | last post by:
I want to write a generic clearForm function to clear the form when the user click CLEAR button. Here's my attempts, because I want to take care all html controls. I think I need to test if the...
2
by: subba_reddy | last post by:
Hi, I have iFrame and command button(webser control) in my aspx page, I want to populate the iframe with someohter page when I click on command button . - SUBBA
0
by: ayneekeaw | last post by:
When I click the update button/link at the Gridview to update the data from drop down list into the SQL. The selected value of drop down list change to default value. How can I fix this problem
2
by: BOS | last post by:
Hi there, I just create a form that contains name, Address, City, State, Zip, Question Checked box, and dropdown list selection for the user to fill-out the answer in the texbox, checkbox or...
8
by: wish | last post by:
Dear all, I would to ask that why the user always faced the different page when user click the back button instead back to page2.php but it go to page5.php..I remember in asp, we use the...
3
by: sbettadpur | last post by:
Hi, Here i have a doubt i have two forms one to fill the data in the input boxs once i filled 1st form then i am submitting the data to next page . So in next page i have one back button if i...
2
by: lisa007 | last post by:
I have a contact form that send goes tru this validation page if everything corrct this php page will echo the form sumited succefully but the problem is evrytime the user clicks submit the data gets...
2
by: kroeh1234 | last post by:
I have an Equipment form with a subform for Utilization. So that the user can close or cancel a change, I created buttons, using the wizard, for close and undo. So, why does Access go through the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.