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
- Sub fclick(ByVal o As Object, ByVal e As EventArgs)
- Dim con, rs, rs1, rs2, rs3, tnm, fnm, fieldtype
- fnm = fnmt.Text
- tnm = tnmd.SelectedItem.Text
- fieldtype = fieldtyped.SelectedItem.Text
- con = Server.CreateObject("ADODB.Connection")
- con.open("provider=sqloledb;Data Source=dp4;Initial Catalog=svit;User ID=sa;Password=dtpt")
- rs = Server.CreateObject("ADODB.Recordset")
- rs.open("alter table " & tnm & " add " & fnm & " " & fieldtype, con)
- rs1 = Server.CreateObject("ADODB.Recordset")
- rs1.cursortype = 2
- rs1.locktype = 3
- rs1.open("select * from fieldinfo ", con)
- rs1.addnew()
- rs1("tnm") = tnm
- rs1("fnm") = fnm
- rs1("fieldtype") = fieldtype
- rs1.update()
- fnmt.Text = ""
- End Sub
- <asp:Button ID="Button1" runat="server" Text="Insert Fields" OnClick="fclick"/>
- <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:svitConnectionString7 %>" SelectCommand="SELECT srno, fnm, fieldtype FROM fieldinfo WHERE (tnm = @tnm)" >
- <SelectParameters>
- <asp:SessionParameter Name="tnm" SessionField="user1" Type="String" />
- </SelectParameters>
- <DeleteParameters>
- <asp:ControlParameter ControlID="GridView1" Name="srno" PropertyName="SelectedValue" />
- </DeleteParameters>
- </asp:SqlDataSource>
-
- <asp:GridView ID="GridView2" runat="server" OnSelectedIndexChanged="selch" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
- <Columns>
- <asp:BoundField DataField="srno" HeaderText="srno" InsertVisible="False" ReadOnly="True"
- SortExpression="srno" />
- <asp:BoundField DataField="fnm" HeaderText="fnm" SortExpression="fnm" />
- <asp:BoundField DataField="fieldtype" HeaderText="fieldtype" SortExpression="fieldtype" />
- <asp:ButtonField CommandName="Select" Text="Delete" />
- </Columns>
- </asp:GridView>
Please help me in this matter as soon as possible.