I bound the Gridview to the database,Now I want that in each row edit link is there,When i click on dat,then the data of data row comes to edit mode...
SOURCE TAB
<asp:GridView ID="GridView1" runat="server" onrowediting="GridView1_RowEditing" AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText="SNo" DataField ="UID" />
<asp:BoundField HeaderText="First Name" DataField ="FirstName" />
<asp:BoundField HeaderText="Last Name" DataField ="LastName" />
<asp:BoundField HeaderText="EMail" DataField ="EMail" />
<asp:BoundField HeaderText="Address" DataField ="Address" />
<asp:BoundField HeaderText="Phone No" DataField ="PhoneNo" />
<asp:TemplateField >
<ItemTemplate>
<asp:LinkButton ID="lnkEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
CODE BEHIND
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data .SqlClient ;
public partial class FrmShowData1 : System.Web.UI.Page
{
string Query;
SqlCommand cmd;
SqlConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
OpenSQLConnection();
Query = "SELECT * FROM Info1";
cmd = new SqlCommand(Query, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill (ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
catch (Exception ex)
{
Label1.Text = ex.Message.ToString();
}
}
private void OpenSQLConnection()
{
try
{
conn = new SqlConnection("Data Source=SONIA-B408A4159\\SQLEXPRESS;Initial catalog=Sonia;Integrated Security=true;");
conn.Open();
}
catch (Exception ex)
{
Label1 .Text = ex.Message.ToString();
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
}
}
When i click on the edit link,then firstly page is postbacked,& when i click again,then in current row textboxes come,but i also want the data to come in textboxes of the current cell....Can someebody tell me ,how to have data in textboxes???