I am adding textbox data into gridview .it should work perfectly.the first row of gridview adding in C# code..it is apper when I run application first row id always put its ok..but want hide this id.means when I run application first time the gridview h
Ave row but have no data means should be hide please help me following code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"> </script>
<script type="text/javascript">
$(function () {
$("body").on("click", "[id*=btnAddRow]", function () {
var id = $("[id*=txtId]").val();
var name = $("[id*=txtName]").val();
var country = $("[id*=txtCountry]").val();
if (id != "" && name != "" && country != "") {
row = $("[id*=GridView1] tr:last-child").clone(true);
$("td:nth-child(1)", row).html(id);
$("td:nth-child(2)", row).html(name);
$("td:nth-child(3)", row).html(country);
$("[id*=GridView1] tbody tr:first").after(row);
}
$("[id*=txtId]").val('');
$("[id*=txtName]").val('');
$("[id*=txtCountry]").val('');
return false;
});
Gridview and textbox
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
Id
</td>
<td>
<asp:TextBox ID="txtId" runat="server" />
</td>
</tr>
<tr>
<td>
Name
</td>
<td>
<asp:TextBox ID="txtName" runat="server" />
</td>
</tr>
<tr>
<td>
Country
</td>
<td>
<asp:TextBox ID="txtCountry" runat="server" />
</td>
</tr>
</table>
<br />
<%-- <asp:Button ID="btnAddRow" Text="Add Row" runat="server" />--%>
<%-- <asp:Button ID="btnUpdate" Text="Update Row" runat="server" />--%>
<input id="btnAddRow" type="button" value="Add Row" />
<input id="btnUpdate" type="button" value="Update Row" />
<br />
<br />
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Id" ItemStyle-CssClass="Id" HeaderText="Id" ItemStyle-Width="30" />
<asp:BoundField DataField="Name" ItemStyle-CssClass="Name" HeaderText=" Student Name" ItemStyle-Width="150" />
<asp:BoundField DataField="Country" ItemStyle-CssClass="Country" HeaderText="Class"
ItemStyle-Width="150" />
<asp:TemplateField>
<ItemTemplate>
<input id="Button1" type="button" value="-" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
C# Code
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Country",typeof(string)) });
dt.Rows.Add(0, "", "");
//dt.Rows.Add(2, "waqas haroon", "Pakistan");
//dt.Rows.Add(3, "Ali Imran", "Pakistan");
//dt.Rows.Add(4, "Waqas haroon", "Pakistan");
GridView1.DataSource = dt;
GridView1.DataBind();
How we can hide gridview first row data using jquery ot css please help me.