asp.net - Procedure not updating the data in the database -


this asp code:

<body>      <form id="form1" runat="server"> <div>      <asp:gridview id="gridview1" runat="server">      <columns>             <asp:commandfield showeditbutton="true" />             <asp:templatefield headertext="id" insertvisible="false">                 <edititemtemplate>                      <asp:textbox id="textbox1" runat="server" text='<%# bind("id") %>'></asp:textbox>                 </edititemtemplate>                  <itemtemplate>                      <asp:label id="lblid" runat="server" text='<%# bind("id") %>'></asp:label>                  </itemtemplate>              </asp:templatefield>               <asp:templatefield headertext="firstname">                 <edititemtemplate>                      <asp:textbox id="textbox2" runat="server" text='<%# bind("firstname") %>'></asp:textbox>                 </edititemtemplate>                  <itemtemplate>                      <asp:label id="lbl" runat="server" text='<%# bind("firstname") %>'></asp:label>                  </itemtemplate>              </asp:templatefield>              </columns>     </asp:gridview>  </div> </form> 

and vb code:

imports system.data.sqlclient imports system.data  partial class testt     inherits system.web.ui.page     public connectionstring string = configurationmanager.connectionstrings("testconnectionstring").connectionstring     public cn sqlconnection = new sqlconnection(connectionstring)     protected sub page_load(sender object, e system.eventargs) handles me.load         dim ds new dataset         dim dt new datatable         if cn.state = connectionstate.closed             cn.open()         end if         dim command sqlcommand = new sqlcommand("selecttest", cn)         command.commandtype = commandtype.storedprocedure         dim da new sqldataadapter(command)         da.fill(ds, "testtt")         dt = ds.tables(0)         gridview1.datasource = dt         if not ispostback             gridview1.databind()         end if         if cn.state = connectionstate.open             cn.close()         end if     end sub     protected sub gridview1_rowupdating(byval sender object, byval e gridviewupdateeventargs) handles gridview1.rowupdating         dim strpersonid string = directcast(gridview1.rows(e.rowindex).findcontrol("textbox1"), textbox).text         dim strlastname string = directcast(gridview1.rows(e.rowindex).findcontrol("textbox2"), textbox).text         try             dim command sqlcommand = new sqlcommand("updatetest", cn)             command.commandtype = commandtype.storedprocedure             command.parameters.addwithvalue("@pid", strpersonid)             command.parameters.addwithvalue("@pfirstname", strlastname)             if cn.state = connectionstate.closed                 cn.open()             end if             command.executenonquery()             msgbox("1 row updated")             if cn.state = connectionstate.open                 cn.close()             end if         catch ex exception             msgbox(ex.message)         end try     end sub     public sub gridview1_rowediting(sender object, e system.web.ui.webcontrols.gridviewediteventargs) handles gridview1.rowediting         gridview1.editindex = e.neweditindex         if not ispostback             gridview1.databind()         end if     end sub end class 

1- columns in grid duplicated means i'm getting selected data stored procedure , data binded in template fields in new columns instead of getting 2 columns i'm getting 4 having same data how can fix this?

2-no errors in rowupdating event working fine data not being updated in database. note stored procedure working fine in sql.. may cause because of duplicated columns mentioned before...

any help??

thank !


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -