how to call javascript function on link button inside a gridview.

D

Deep

Hi,
I have taken a gridview and in ItemTemplate I have taken a link
button for insert record.
when any body fills text box and then click insert record. Record
inserted successfully. Textbox are also inside itemtemplate of
gridview.

I want before inserting data textbox should be checked for empty
data.

How to call javascript function from link button and how to access
that textbox value in javascript function.

My html form is like that
<form id="form1" runat="server">
<div>

</div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowdeleting="GridView1_RowDeleting"
onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating"
onrowcommand="GridView1_RowCommand" ShowFooter="true">
<Columns>
<asp:TemplateField HeaderText="EmpId">
<FooterTemplate>
<asp:LinkButton ID="lnkAdd" runat="server"
CommandName="AddNew"
onclick="lnkAdd_Click">Insert</asp:LinkButton>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblId" runat="server" Text='<
%#Eval("EmpId")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<EditItemTemplate>
<asp:TextBox ID="txtName" runat="server" Text='<
%#Eval("Name")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewName" runat="server"></
asp:TextBox>
</FooterTemplate>
<ItemTemplate><%#Eval("Name")%></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Age">
<EditItemTemplate>
<asp:TextBox ID="txtAge" runat="server" Text='<
%#Eval("Age")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewAge" runat="server"></
asp:TextBox>
</FooterTemplate>
<ItemTemplate><%#Eval("Age")%></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Salary">
<EditItemTemplate>
<asp:TextBox ID="txtSalary" runat="server" Text='<
%#Eval("Salary")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewSalary" runat="server"></
asp:TextBox>
</FooterTemplate>
<ItemTemplate><%#Eval("Salary")%></ItemTemplate>
</asp:TemplateField>
</Columns>

</asp:GridView>
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</
asp:LinkButton>
</form>

Please help me

Thanks in Advance
 
J

Jeff Johnson

Please help me

Here's the best help I can give: This question has nothing to do with C# and
everything to do with ASP.NET. Repost it in an ASP.NET group and you'll get
the help you're looking for.
 
M

Mr. Arnold

Deep said:
Hi,
I have taken a gridview and in ItemTemplate I have taken a link
button for insert record.
when any body fills text box and then click insert record. Record
inserted successfully. Textbox are also inside itemtemplate of
gridview.

I want before inserting data textbox should be checked for empty
data.

How to call javascript function from link button and how to access
that textbox value in javascript function.


</asp:GridView>
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</
asp:LinkButton>
</form>

<http://msdn.microsoft.com/en-us/lib...controls.linkbutton.onclientclick(VS.80).aspx>

<http://www.tizag.com/javascriptT/javascript-getelementbyid.php>

If you have anymore asp.net questions, they would be better answered in the
ASP.NET fourm.

microsoft.public.dotnet.framework.aspnet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top