Hello, i need some help here, i want to change Edit,Select,Delete linkbutton in the gridview to be outside the gridview, i have tried to hide the 3 button and make another button outside gridview, but i dont know how to make a link between all the button. this is my code
asp code:
<%@ Page Language="VB"
AutoEventWireup="false"
CodeFile="Default.aspx.vb"
Inherits="_Default"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
CellPadding="4"
DataKeyNames="NDP"
DataSourceID="SqlDataSource1"
ForeColor="#333333"
GridLines="None"
style="left: 0%; position: relative; top: 0%">
<FooterStyle BackColor="#507CD1"
Font-Bold="True"
ForeColor="White" />
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:Button ID="LinkButton1"
runat="server"
CausesValidation="True"
CommandName="Update"
Text="Update">
</asp:Button>
<asp:Button ID="LinkButton2"
runat="server"
CausesValidation="False"
CommandName="Cancel"
Text="Cancel">
</asp:Button>
</EditItemTemplate>
<ItemTemplate>
<asp:Button ID="btnEdit"
runat="server"
CommandName="Edit"
Text="Edit"
Visible="False"
OnClick="BtnEdit2_Click">
</asp:Button>
<asp:Button ID="btnSelect"
runat="server"
CausesValidation="False"
CommandName="Select"
Text="Select">
</asp:Button>
<asp:Button ID="btnDelete"
runat="server"
CausesValidation="False"
CommandName="Delete"
Text="Delete" Visible="False">
</asp:Button>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="NDP"
SortExpression="NDP">
<EditItemTemplate>
<asp:Label ID="Label1"
runat="server"
Text='<%# Eval("NDP") %>'>
</asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1"
runat="server"
Text='<%# Bind("NDP") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Nama"
SortExpression="Nama">
<EditItemTemplate>
<asp:TextBox ID="TextBox1"
runat="server"
Text='<%# Bind("Nama") %>'>
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2"
runat="server"
Text='<%# Bind("Nama") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Semester" SortExpression="Semester">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Semester") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Semester") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sesi" SortExpression="Sesi">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Sesi") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Sesi") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="No_Kad_Pengenalan" SortExpression="No_Kad_Pengenalan">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("No_Kad_Pengenalan") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("No_Kad_Pengenalan") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="No_Telefon" SortExpression="No_Telefon">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("No_Telefon") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("No_Telefon") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:Button ID="btnEdit2" runat="server" Style="left: 576px; position: absolute;
top: 112px" Text="Edit" />
<asp:Button ID="btnSelect2" runat="server" Style="left: 568px; position: absolute; top: 184px"
Text="Delete" />
<asp:SqlDataSource ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString2 %>"
DeleteCommand="DELETE FROM [Maklumat] WHERE [NDP] = @NDP"
InsertCommand="INSERT INTO [Maklumat] ([NDP], [Nama], [Semester], [Sesi], [No_Kad_Pengenalan], [No_Telefon]) VALUES (@NDP, @Nama, @Semester, @Sesi, @No_Kad_Pengenalan, @No_Telefon)"
SelectCommand="SELECT * FROM [Maklumat]"
UpdateCommand="UPDATE [Maklumat] SET [Nama] = @Nama, [Semester] = @Semester, [Sesi] = @Sesi, [No_Kad_Pengenalan] = @No_Kad_Pengenalan, [No_Telefon] = @No_Telefon WHERE [NDP] = @NDP">
<DeleteParameters>
<asp:Parameter Name="NDP" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Nama" Type="String" />
<asp:Parameter Name="Semester" Type="String" />
<asp:Parameter Name="Sesi" Type="String" />
<asp:Parameter Name="No_Kad_Pengenalan" Type="String" />
<asp:Parameter Name="No_Telefon" Type="String" />
<asp:Parameter Name="NDP" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="NDP" Type="String" />
<asp:Parameter Name="Nama" Type="String" />
<asp:Parameter Name="Semester" Type="String" />
<asp:Parameter Name="Sesi" Type="String" />
<asp:Parameter Name="No_Kad_Pengenalan" Type="String" />
<asp:Parameter Name="No_Telefon" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
vb code:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub LinkButton4_Click(ByVal sender As Object, ByVal e As System.EventArgs)
GridView1.ShowFooter = True
End Sub
Protected Sub LinkButton5_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim txtNDP As TextBox = CType(GridView1.FooterRow.FindControl("txtNDP"), TextBox)
Dim txtNama As TextBox = CType(GridView1.FooterRow.FindControl("txtnama"), TextBox)
Dim txtsemester As TextBox = CType(GridView1.FooterRow.FindControl("txtsemester"), TextBox)
Dim txtSesi As TextBox = CType(GridView1.FooterRow.FindControl("txtSesi"), TextBox)
Dim txtKpengenalan As TextBox = CType(GridView1.FooterRow.FindControl("txtKpengenalan"), TextBox)
Dim txtTelefon As TextBox = CType(GridView1.FooterRow.FindControl("txtTelefon"), TextBox)
SqlDataSource1.InsertParameters.Item("NDP").DefaultValue = txtNDP.Text
SqlDataSource1.InsertParameters.Item("Nama").DefaultValue = txtNama.Text
SqlDataSource1.InsertParameters.Item("Semester").DefaultValue = txtsemester.Text
SqlDataSource1.InsertParameters.Item("Sesi").DefaultValue = txtSesi.Text
SqlDataSource1.InsertParameters.Item("No_Kad_Pengenalan").DefaultValue = txtKpengenalan.Text
SqlDataSource1.InsertParameters.Item("No_Telefon").DefaultValue = txtTelefon.Text
SqlDataSource1.Insert()
GridView1.ShowFooter = False
End Sub
End Class
i hope someone can help me....thanks....