Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
4
Answers
Add add row in first row in gridview inline grid c#
Manoj Maharana
7y
677
1
Reply
How do i add first row of gridview as add row in inline gridview (asp .net).
Here is the code:
<asp:GridView ID=
"gvTaskDetails"
runat=
"server"
Width=
"100%"
CssClass=
"table table-bordered"
AutoGenerateColumns=
"false"
Font-Names=
"Arial"
HeaderStyle-BackColor=
"#e7f2ff"
AllowPaging=
"true"
ShowFooter=
"true"
OnPageIndexChanging=
"gvTaskDetails_PageIndexChanging"
OnRowCommand=
"gvTaskDetails_RowCommand"
OnRowEditing=
"gvTaskDetails_RowEditing"
OnRowUpdating=
"gvTaskDetails_RowUpdating"
OnRowCancelingEdit=
"gvTaskDetails_RowCancelingEdit"
DataKeyNames=
"ID"
OnRowDataBound=
"gvTaskDetails_RowDataBound"
PageSize=
"10"
>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID=
"hdnID"
runat=
"server"
Value=
'<%#Eval("ID") %>'
/>
<%--<asp:Label ID=
"lblCustomerID"
runat=
"server"
Text=
'<%# Eval("ID")%>'
></asp:Label>--%>
</ItemTemplate>
<FooterTemplate>
<%--<asp:TextBox ID=
"txtCustomerID"
Width=
"40px"
MaxLength=
"5"
runat=
"server"
></asp:TextBox>--%>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Company Name"
>
<ItemTemplate>
<asp:Label ID=
"lblcmpnm"
Text=
'<%#Eval("Companynm")%>'
runat=
"server"
> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID=
"txtcmpnm"
runat=
"server"
CssClass=
"form-control"
Text=
'<%#Eval("Companynm")%>'
></asp:TextBox>
<%-- <span id=
"erroreml1"
runat=
"server"
style=
"color:red"
></span>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID=
"txtcmpnm"
runat=
"server"
CssClass=
"form-control"
placeholder=
"Company Name"
></asp:TextBox>
<span id=
"errorcmpnm"
runat=
"server"
style=
"color:red"
></span>
<%-- <asp:RequiredFieldValidator ID=
"rfvPrice"
ControlToValidate=
"txteml"
runat=
"server"
ErrorMessage=
"Required"
ForeColor=
"Red"
></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID=
"regexEmailValid"
runat=
"server"
ForeColor=
"Red"
ValidationExpression=
"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate=
"txteml"
ErrorMessage=
"Invalid Email Format"
></asp:RegularExpressionValidator>--%>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Email"
>
<ItemTemplate>
<asp:Label ID=
"lblTname"
Text=
'<%#Eval("Email")%>'
runat=
"server"
> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID=
"txteml"
runat=
"server"
CssClass=
"form-control"
Text=
'<%#Eval("Email")%>'
></asp:TextBox>
<span id=
"erroreml1"
runat=
"server"
style=
"color:red"
></span>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID=
"txteml"
runat=
"server"
CssClass=
"form-control"
placeholder=
"Enter Email"
></asp:TextBox>
<span id=
"erroreml"
runat=
"server"
style=
"color:red"
></span>
<%-- <asp:RequiredFieldValidator ID=
"rfvPrice"
ControlToValidate=
"txteml"
runat=
"server"
ErrorMessage=
"Required"
ForeColor=
"Red"
></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID=
"regexEmailValid"
runat=
"server"
ForeColor=
"Red"
ValidationExpression=
"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate=
"txteml"
ErrorMessage=
"Invalid Email Format"
></asp:RegularExpressionValidator>--%>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Phone"
>
<ItemTemplate>
<asp:Label ID=
"lblproject"
Text=
'<%#Eval("Phone")%>'
runat=
"server"
> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID=
"txtph"
TextMode=
"MultiLine"
runat=
"server"
CssClass=
"form-control"
Text=
'<%#Eval("Phone")%>'
></asp:TextBox>
<span id=
"errorph1"
runat=
"server"
style=
"color:red"
></span>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID=
"txtph"
TextMode=
"MultiLine"
runat=
"server"
CssClass=
"form-control"
placeholder=
"Enter Phone Number"
></asp:TextBox>
<span id=
"errorph"
runat=
"server"
style=
"color:red"
></span>
<%-- <asp:RequiredFieldValidator ID=
"rfvPrices"
ControlToValidate=
"txtph"
runat=
"server"
ErrorMessage=
"Required"
ForeColor=
"Red"
></asp:RequiredFieldValidator>--%>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Category"
>
<ItemTemplate>
<asp:Label ID=
"lblEmpName"
Text=
'<%#Eval("Category")%>'
runat=
"server"
> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID=
"txtcat"
runat=
"server"
CssClass=
"form-control"
Text=
'<%#Eval("Category")%>'
></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID=
"txtcat"
CssClass=
"form-control"
runat=
"server"
placeholder=
"Enter Category"
></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"City"
>
<ItemTemplate>
<asp:Label ID=
"lblSdate"
Text=
'<%#Eval("City")%>'
runat=
"server"
> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID=
"txtcity"
runat=
"server"
CssClass=
"form-control"
Text=
'<%#Eval("City")%>'
></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID=
"txtcity"
runat=
"server"
CssClass=
"form-control"
placeholder=
"Enter City"
></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Comments"
>
<ItemTemplate>
<asp:Label ID=
"lblcmnts"
Text=
'<%#Eval("Comments")%>'
runat=
"server"
> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID=
"txtcmnts"
TextMode=
"MultiLine"
runat=
"server"
CssClass=
"form-control"
Text=
'<%#Eval("Comments")%>'
></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID=
"txtcmnts"
TextMode=
"MultiLine"
runat=
"server"
CssClass=
"form-control"
placeholder=
"Enter Comments"
></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Action"
>
<ItemTemplate>
<asp:LinkButton runat=
"server"
Text=
"Edit"
ID=
"imgEdit"
CommandName=
"Edit"
CommandArgument=
'<%#Eval("ID") %>'
><img src=
"images/edit.png"
alt=
"Edit"
title=
"Edit Title"
/> </asp:LinkButton>
<asp:LinkButton ID=
"imgDelete"
Text=
"Delete"
runat=
"server"
OnClientClick=
"return confirm('Are you sure to delete Task?');"
CommandName=
"Delete"
CommandArgument=
'<%#Eval("ID") %>'
><img src=
"images/cross.png"
alt=
"Edit"
title=
"Delete Task"
/></asp:LinkButton>
<br />
<asp:LinkButton ID=
"lnkopenpopup"
runat=
"server"
Text=
"Appointment"
Style=
"float: left; margin-right: 5px;"
CommandName=
"App"
CommandArgument=
'<%#Eval("ID") %>'
CssClass=
"label label-sm label-success"
></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:ImageButton ID=
"imgbtnUpdate"
runat=
"server"
CommandName=
"Update"
ImageUrl=
"../Content/images/user_edit.png"
ToolTip=
"Update"
OnClientClick=
"return GetGridFooterRowvalues1()"
/>
<asp:ImageButton ID=
"imgbtnCancel"
runat=
"server"
CommandName=
"Cancel"
ImageUrl=
"images/cross.png"
ToolTip=
"Cancel"
/>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID=
"btnsave"
runat=
"server"
Text=
"Add New"
class
=
"btn icon-btn btn-success btn-sm"
OnClientClick=
"return GetGridFooterRowvalues()"
OnClick=
"btnsave_Click"
/>
</FooterTemplate>
</asp:TemplateField>
<%-- <asp:CommandField ShowEditButton=
"True"
/>--%>
</Columns>
<PagerStyle HorizontalAlign=
"Right"
CssClass=
"paging-d"
/>
<AlternatingRowStyle CssClass=
"tr2"
/>
<%-- <AlternatingRowStyle BackColor=
"#C2D69B"
/>--%>
</asp:GridView>
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
Sync GoogleDrive with pc using C#
How to open an XML file in a richtextbox and.....++