I'm trying to get the value from detailsview to formview. I want to set the Book ID/ISBN in formview insert textbox to Book ID/ISBN value from detailsview.
Here's a sample of my code:
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
CellPadding="4" DataKeyNames="bookid" DataSourceID="detailsDataSource"
ForeColor="#333333" GridLines="None" Height="50px" Width="">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<RowStyle BackColor="#EFF3FB" />
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<FooterTemplate>
<asp:GridView ID="GridView2" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="reservationid" DataSourceID="reserveDataSource"
ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="EmployeeID" HeaderText="Reserved by"
SortExpression="EmployeeID" />
<asp:BoundField DataField="reservedate" HeaderText="Reserved date"
SortExpression="reservedate" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="reservationid"
DataSourceID="reserveDataSource">
<EditItemTemplate>
reservationid:
<asp:Label ID="reservationidLabel1" runat="server"
Text='<%# Eval("reservationid") %>' />
<br />
bookid:
<asp:TextBox ID="bookidTextBox" runat="server" Text='<%# Bind("bookid") %>' />
<br />
EmployeeID:
<asp:TextBox ID="EmployeeIDTextBox" runat="server"
Text='<%# Bind("EmployeeID") %>' />
<br />
reservedate:
<asp:TextBox ID="reservedateTextBox" runat="server"
Text='<%# Bind("reservedate") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
Book ID/ISBN:
<asp:TextBox ID="bookidTextBox" runat="server"
Text='<%# Bind("bookid") %>'/>
<br />
Employee ID:
<asp:TextBox ID="EmployeeIDTextBox0" runat="server"
Text='<%# Bind("EmployeeID") %>' />
<br />
Reserve date:
<asp:TextBox ID="reservedateTextBox0" runat="server"
Text='<%# Bind("reservedate") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Reserve" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
So what I'm trying to do is when a user click the Insert/Reserve book linkbutton the Book ID/ISBN is already set to the Book ID/ISBN in formview insert mode as default.
Any help would be much appreciated ;)
Thanks in advance.
Can you try and check the DetailsView1.SelectedValue
<asp:TextBox ID="bookidTextBox" runat="server"
Text='<%# DetailsView1.SelectedValue %>'/>
Edit:
Now if you want to bind that value to your Insert function of your DetailsView, it will not behave like the other control, since you are using the Bind method for the other control and it provides two way binding.
Now you need to pass that value to inserting evet of DetailsView like as we are assigning values using DetailsView1.SelectedValue but not binding the value.
I hope you understand this theory.
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
e.Values["bookid"] = ((TextBox)DetailsView1.FindControl("bookidTextBox")).Text;
}
Related
I have a grid view with some command field (delete, edit),they work until I put the grid view in an update panel.
it is a asp.net web form.
thank a lot... I'm not use to work with asp.net
<h2><%: Title %>Contact List</h2>
<h3>click any contact to edit...</h3>
<asp:Button ID="insert1" runat="server" Height="21px" OnClick="insert1_Click" Text="new contact" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
<ContentTemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:contact_atidConnectionString %>"
SelectCommand="SELECT * FROM [contact_list]"
DeleteCommand="delete from [contact_list] where id=#id"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="id"
DataSourceID="SqlDataSource1" Height="30px"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="453px"
OnRowDeleted="GridView1_RowDeleted" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" EnablePersistedSelection="True" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal">
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" ReadOnly="True" />
<asp:BoundField DataField="first name" HeaderText="first name" SortExpression="first name" />
<asp:BoundField DataField="last name" HeaderText="last name" SortExpression="last name" />
<asp:CommandField ShowDeleteButton="True" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<SortedAscendingCellStyle BackColor="#F4F4FD" />
<SortedAscendingHeaderStyle BackColor="#5A4C9D" />
<SortedDescendingCellStyle BackColor="#D8D8F0" />
<SortedDescendingHeaderStyle BackColor="#3E3277" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
I found my problem! I simply forget to put the list view that the commad button have to open in the update panel.
here is the correct code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="id"
DataSourceID="SqlDataSource1" Height="30px"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="453px"
OnRowDeleted="GridView1_RowDeleted" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" EnablePersistedSelection="True" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"
CssClass="table table-striped">
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" ReadOnly="True" />
<asp:BoundField DataField="first name" HeaderText="first name" SortExpression="first name" />
<asp:BoundField DataField="last name" HeaderText="last name" SortExpression="last name" />
<asp:CommandField ShowDeleteButton="True" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<SortedAscendingCellStyle BackColor="#F4F4FD" />
<SortedAscendingHeaderStyle BackColor="#5A4C9D" />
<SortedDescendingCellStyle BackColor="#D8D8F0" />
<SortedDescendingHeaderStyle BackColor="#3E3277" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:contact_atidConnectionString %>"
SelectCommand="SELECT * FROM [contact_list]"
DeleteCommand="delete from [contact_list] where id=#id"></asp:SqlDataSource>
<asp:Panel runat="server">
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource2" Visible="true">
<ItemTemplate>
<tr runat="server">
<td>
<asp:LinkButton ID="EditButton" runat="Server" Text="SAVE" CommandName="save" OnClick="EditButton_Click" CssClass="btn btn-default btn-lg" BackColor="MediumSpringGreen" />
</td>
<td>
<asp:TextBox ID="TextBox101" runat="Server" Text='<%#Eval("id") %>' Visible="false" class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="FirstNameLabel" runat="Server" Text='<%#Eval("first name") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="LastNameLabel" runat="Server" Text='<%#Eval("last name") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox1" runat="Server" Text='<%#Eval("[street]") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox5" runat="Server" Text='<%#Eval("born date") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox2" runat="Server" Text='<%#Eval("house number") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox3" runat="Server" Text='<%#Eval("telephone") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox4" runat="Server" Text='<%#Eval("pelephone") %>' class="form-control input-sm" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
thank you :)
I have gridview with footer and addbutton on that, how to add new rows if I push the addbutton ? so I can enter new data on that. I also want save them all into database, can somebody explain please
this my front code:
<asp:GridView ID="GridView1" AutoGenerateColumns="False" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" ShowFooter="True" Width="707px" >
<AlternatingRowStyle BackColor="White"/>
<Columns>
<asp:TemplateField>
<FooterTemplate>
<asp:Button ID="AddProduct" runat="server" CssClass="button" Text="Add" onclick="AddProduct_Click" ></asp:Button>
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField HeaderStyle-Width="120px" HeaderText="Id Trans" DataField="Id_Trans" ShowHeader="False" Visible="False">
<HeaderStyle Width="120px"></HeaderStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="Nama Barang" SortExpression="Nama_Item">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="tampilbarang" DataTextField="Nama_Item" DataValueField="Id_Item">
</asp:DropDownList>
<asp:SqlDataSource ID="tampilbarang" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Item]"></asp:SqlDataSource>
</ItemTemplate>
<HeaderStyle Width="120px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="QTY">
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ItemTemplate>
<HeaderStyle Width="120px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Keterangan Penggunaan">
<ItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</ItemTemplate>
<HeaderStyle Width="120px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Aksi">
<ItemTemplate>
<asp:Button ID="Del" runat="server" Height="22px" Text="Delete" Width="57px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
There are a lot of things to explain in answer your question, so instead I'd recommend a good tutorial - try this - https://quickstarts.asp.net/quickstartv20/aspnet/doc/ctrlref/data/gridview.aspx
You can add a button in footer template like this example:
<asp:gridview ID="Gridview1" runat="server" ShowFooter="true" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="RowNumber" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Header 1">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Header 2">
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Header 3">
<ItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</ItemTemplate>
<FooterStyle HorizontalAlign="Right" />
<FooterTemplate>
<asp:Button ID="ButtonAdd" runat="server" Text="Add New Row" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
I created a web page Default6.aspx containing a gridview.
This gridview contains w column "radio button" (just one radio button can be selected)
I have a button that when I click,the Id of the row checked will be shown.
The problem that after click on the button,the checked radio button becomes unchecked and the gridview loads new data.
I couldn't really understand why.
Note: I have the same code in another Default5.aspx and it works.
this is the code of gridview:
<div style ="height:250px; width:1092px; overflow:auto;" spellcheck="True">
<asp:GridView ID="GridView2" runat="server"
BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" CellSpacing="4" GridLines="Vertical" Height="160px"
OnSelectedIndexChanged="GridView2_SelectedIndexChanged" Width="271px" ForeColor="Black"
ShowHeaderWhenEmpty="True" AutoPostBack="false">
<AlternatingRowStyle BackColor="White" />
<Columns >
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:CheckBox ID="chkDelete" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Main" >
<ItemTemplate>
<asp:RadioButton ID ="radioButton1" HeaderText="Main" runat="server"
onclick = "RadioCheck(this);" AutoPostBack ="False" Checked="False" CausesValidation="True" />
<asp:HiddenField ID="HiddenField1" runat="server" Value = '<%#Eval("id")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ID" Visible="false">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Eval("id") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#80FF00" Font-Bold="True" ForeColor="Black" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#CCCCCC" BorderStyle="Solid" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>
</div>
and this is the code of the button:
<asp:Button ID="Button1" runat="server" BackColor="#80FF00" Font-Size="Large" OnClick="Button1_Click" Text="Delete unselected rows" Width="200px" />
for the test I created another button that just shows me a message "hello" when I click on it..and when I did (even I don't check a radio button),the gridview became refreshed..
what can be that?
thank you
Consider wrapping your button and the label in an updatepanel control, which uses AJAX to refresh their contents. The rest of the page will not be reloaded and the action will not affect the browser navigation.
the answer is:
if (!IsPostBack)
{ //my code}
else
{ //nothing to do}
I am trying to get the required field validation to fire only for the specific row when the add button is clicked. But right now, when I click any add button, it fires the required field validation for all nested grid rows. The code for the nested gridview and the image of the gridviews is the following. I also tried to use validation groups, attempting to get unique validation groups for each nested gridview row, but couldn't get it to work.
<asp:GridView ID="GrdXML" runat="server" AllowSorting="false"
AutoGenerateColumns="False" CellPadding="0"
ForeColor="#333333" GridLines="Horizontal" onrowdeleting="GrdXML_RowDeleting" OnRowDataBound="OnRowDataBound"
ShowFooter="false" CssClass="xmlgrid" OnSorting="GrdXML_Sorting" DataKeyNames="ContractRecordID">
<Columns>
<asp:TemplateField HeaderText="Contract Start Date" SortExpression="ContractStartDate">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("ContractStartDate") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="30%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Contract End Date" SortExpression="ContractEndDate">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("ContractEndDate") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="50%" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="BtnDelete" runat="server"
CommandArgument='<%# Eval("ContractRecordID") %>' CommandName="Delete"
onclick="BtnDelete_Click" Text="Delete" Width="60px" />
<ajaxToolkit:ConfirmButtonExtender ID="BtnDelete_ConfirmButtonExtender"
runat="server" ConfirmText="Are you sure you want to Delete?" Enabled="True"
TargetControlID="BtnDelete">
</ajaxToolkit:ConfirmButtonExtender>
</ItemTemplate>
<ItemStyle Width="40px" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Literal runat="server" ID="lit1" Text="<tr id='trGrid'><td colspan='100%'>" />
<asp:GridView ID="projectCodeGridView" runat="server" AllowSorting="false" CellPadding="4" ForeColor="#333333" GridLines="Horizontal" AutoGenerateColumns="false" ShowFooter="true" OnRowCommand="ProjectCodeGridView_RowCommand" OnRowCreated="ProjectCodeGridView_RowCreated" OnRowDataBound="ProjectCodeGridView_RowDataBound" OnRowDeleting="ProjectCodeGridView_RowDeleting" DataKeyNames="ContractProjectCodeID" BorderStyle="None" BorderWidth="0">
<Columns>
<asp:TemplateField HeaderText="Project Codes" SortExpression="ContractProjectCode" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("ContractProjectCode") %>' CssClass="projectcodelabel"></asp:Label>
</ItemTemplate>
<ItemStyle Width="100%" />
<FooterTemplate>
<asp:TextBox ID="projectCodeTextBox" runat="server" ValidationGroup='<%# "PC" + Eval("ContractProjectCodeID") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="projectCodeRequiredFieldValidator" runat="server"
ControlToValidate="projectCodeTextBox" ErrorMessage="Project Code Required" ForeColor="Red" Display="Static" ValidationGroup='<%# "PC" + Eval("ContractProjectCodeID") %>' Enabled="false"></asp:RequiredFieldValidator>
</FooterTemplate>
<FooterStyle Width="100%" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="BtnDelete1" runat="server"
CommandArgument='<%# Eval("ContractProjectCodeID") %>' CommandName="Delete"
onclick="BtnDelete1_Click" Text="Delete" Width="60px" />
<ajaxToolkit:ConfirmButtonExtender ID="BtnDelete1_ConfirmButtonExtender"
runat="server" ConfirmText="Are you sure you want to Delete?" Enabled="True"
TargetControlID="BtnDelete1">
</ajaxToolkit:ConfirmButtonExtender>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="BtnAdd" runat="server" onclick="BtnAdd_Click" Text="Add" Width="60px" ValidationGroup='<%# "PC" + Eval("ContractProjectCodeID") %>' CommandName="Add" />
</FooterTemplate>
<FooterStyle Width="100%" />
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#F7F6F3" Font-Bold="True" />
</asp:GridView>
<asp:Literal runat="server" ID="lit2" Text="</td></tr>" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="Black" CssClass="padding" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" CssClass="padding" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
For the validation control of each row you are adding the ValidationGroup='<%# "PC" + Eval("ContractProjectCodeID") %>'. As you are saying, that the validation triggers for the wrong row, it could be that ContractProjectCodeID may not be unique for each row. I think what you can do is add row index to the validation group
ValidationGroup='<%# "PC" + Container.DataItemIndex + Eval("ContractProjectCodeID")
I am using asp.net framework 3.5 and c# 2.0. I am able to bind data in to gridview.
Actually I want to display Image on mouseover event on asp:linkButton, which is used in grid view
<asp:GridView ID="gvTemplate" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True" Width="100%"
OnRowCommand="gvTemplate_RowCommand" OnRowDataBound="RowDataBound" OnPageIndexChanging="gvTemplate_PageIndexChanging">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Sr. No">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Template Name" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:LinkButton ID="lBtTempID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"tempName") %>'
CommandName='<%# DataBinder.Eval(Container.DataItem,"tempID") %>' CommandArgument="tempID" onmouseover="javascript:showImage(this.id)"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Template Type">
<ItemTemplate>
<asp:Label ID="lbltempType" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"tempType") %>' />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
If you can use jquery it would be like this
$('.lBtTempClass').mouseover(function() {
/// Do your code
});
you should add a css class to link button
<asp:LinkButton ID="lBtTempID" CssClass="lBtTempClass" runat="server" >