Hi! I used this below code it’s worked.
<div>
<script type="text/javascript" src="Scripts/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=GridView1] td").bind("click", function () {
var date = $('[id*=txt1]').val();
$('[id*=txt1]').val(date + ' ' + $(this).html());
});
return false;
});
</script>
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="FirstName" HeaderText="FirstName" ItemStyle-Width="150" />
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
<asp:BoundField DataField="LastName" HeaderText="LastName" ItemStyle-Width="150" />
</Columns>
</asp:GridView>
<br />
<br />
<asp:TextBox ID="txt1" runat="server" Text="Default"/>
</div>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("FirstName"), new DataColumn("Name"), new DataColumn("LastName") });
dt.Rows.Add("Pulodov", "Rustam", " Abdulloevich");
dt.Rows.Add("Safarov", "Sarabek", "Rustamovich");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
But I have problem when I click twice in cell it’s add cell values twice like this: Default Rustam Rustam. I want only be in textbox always Default and value. For example: Default Sarabek. If I clicked twice in Sarabek cells must be Default Sarabek. Not Default Sarabek Sarabek. Who is you can help me?