470,631 Members | 1,557 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,631 developers. It's quick & easy.

GridView Disappears.......

8
Hello,
I am having a button control and gridview control (programmatically bind to d/b).When i click on button,fclick() sub is fired.After this the GridView disappears.The buttonclick updates the same table to which gridView is bound.

The subroutine for button click is as below:
-------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1.   Sub fclick(ByVal o As Object, ByVal e As EventArgs)
  2.  
  3.         Dim con, rs, rs1, rs2, rs3, tnm, fnm, fieldtype
  4.         fnm = fnmt.Text
  5.         tnm = tnmd.SelectedItem.Text
  6.         fieldtype = fieldtyped.SelectedItem.Text
  7.         con = Server.CreateObject("ADODB.Connection")
  8.         con.open("provider=sqloledb;Data Source=dp4;Initial Catalog=svit;User ID=sa;Password=dtpt")
  9.         rs = Server.CreateObject("ADODB.Recordset")
  10.         rs.open("alter table " & tnm & " add " & fnm & " " & fieldtype, con)
  11.         rs1 = Server.CreateObject("ADODB.Recordset")
  12.         rs1.cursortype = 2
  13.         rs1.locktype = 3
  14.         rs1.open("select * from fieldinfo ", con)
  15.         rs1.addnew()
  16.         rs1("tnm") = tnm
  17.         rs1("fnm") = fnm
  18.         rs1("fieldtype") = fieldtype
  19.         rs1.update()
  20.  
  21.         fnmt.Text = ""
  22.  
  23.  
  24.  
  25.     End Sub
  26. <asp:Button ID="Button1" runat="server" Text="Insert Fields" OnClick="fclick"/>
  27. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:svitConnectionString7 %>" SelectCommand="SELECT srno, fnm, fieldtype FROM fieldinfo WHERE (tnm = @tnm)" >
  28.             <SelectParameters>
  29.                 <asp:SessionParameter Name="tnm" SessionField="user1" Type="String" />
  30.             </SelectParameters>
  31.             <DeleteParameters>
  32.                 <asp:ControlParameter ControlID="GridView1" Name="srno" PropertyName="SelectedValue" />
  33.             </DeleteParameters>
  34.         </asp:SqlDataSource>
  35.         &nbsp;
  36.  
  37.         <asp:GridView ID="GridView2" runat="server" OnSelectedIndexChanged="selch" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
  38.             <Columns>
  39.                 <asp:BoundField DataField="srno" HeaderText="srno" InsertVisible="False" ReadOnly="True"
  40.                     SortExpression="srno" />
  41.                 <asp:BoundField DataField="fnm" HeaderText="fnm" SortExpression="fnm" />
  42.                 <asp:BoundField DataField="fieldtype" HeaderText="fieldtype" SortExpression="fieldtype" />
  43.                 <asp:ButtonField CommandName="Select" Text="Delete" />
  44.             </Columns>
  45.         </asp:GridView>
---------------------------------------------

Please help me in this matter as soon as possible.
Mar 19 '07 #1
0 1073

Post your reply

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

Similar topics

reply views Thread by sck10 | last post: by
2 posts views Thread by antonyliu2002 | last post: by
reply views Thread by Don Miller | last post: by
1 post views Thread by Froefel | last post: by
1 post views Thread by John Devlon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.