I am using a gridview in aspx and i have two pages that registration and details.aspx once registration completed it should goto details page in details.aspx i have kept a gridview in that GV i am supposed be use row command event for a button it should show the all the rsults for the students with the edit button as the last column for all the students i used item template for that. but in row command event i dont know the function to write if user clicking edit it should goto the edit page using the userid the id should be noon editable mode and other fields can editable.Gridview(Details.aspx) </asp:GridView>--%> <asp:GridView ID="GridView3" runat="server" CellPadding="3" ForeColor="#333333" GridLines="None" AutoGenerateColumns="false" OnRowCommand="GridView3_RowCommand" OnSelectedIndexChanged="GridView3_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True"/>
<asp:BoundField DataField="Password" HeaderText="Password" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" />
<asp:BoundField DataField="EMail" HeaderText="Emaid-ID" />
<asp:BoundField DataField="PhoneNo" HeaderText="Phone Number" />
<asp:BoundField DataField="Location" HeaderText="Location" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="btnedit" runat="server" Text="Edit" CommandName="Edit" CommandArgument="UserName"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</div>
</form>
details.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Web.Configuration.Common;
public partial class GridView_Practice : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connection2 = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connection1"].ConnectionString;
SqlConnection con = new SqlConnection(connection2);
con.Open();
SqlCommand cmd = new SqlCommand("select * from User_Information", con);
SqlDataReader rdr = cmd.ExecuteReader();
GridView3.DataSource = rdr;
GridView3.DataBind();
con.Close();
}
protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
{
}
protected void GridView3_SelectedIndexChanged(object sender, EventArgs e)
{
}
}