ON the Link button Click which is in the Grid1 want to focus on Grid 2

Posted by Lalitha86 under C# on 8/8/2012 | Points: 10 | Views : 845 | Status : [Member] | Replies : 12
when we click the button in inside the Grid view it should Focus on the Other Grid view Data




Responses

Posted by: Gopesh9 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
You can do like this, if you are clicking on the button in the 1st grid view, just make the 2nd grid view to be visible.

G. S.
.Net Developer

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lalitha86 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
on the linkbutton click i want to focus the whole 2nd grid

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
Focus in the sense that you want to make the 2nd grid visible, right??

G. S.
.Net Developer

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lalitha86 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
no it is visible
but the user needs to scroll and see the data
i want the user to directly focus the grid2 (without scroll option )


Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
See you have to write the two grids in seperate Div tag using the html, now when the user clicks on the link button you just have to call the div tag of the 2nd grid view using the id of the div...

So it will go to that position of your html page where the 2nd grid is there.
You have to include this befor the div tag
<td valign="top" colspan="3" height="42"> 

Now when you use the link button just use
<a href="#top">LinkButton


G. S.
.Net Developer

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lalitha86 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
Below is my code bout not working

<div class="content">


<div>
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>

<td align="right">All Values in <img src="../../include/images/rs_b.gif" alt="" border="0" />Cr.</td>

</tr>
<tr>
<td bgcolor="#d6d6d6">
<asp:GridView ID="gvReport" width="100%"
runat="server" CellPadding="4" CellSpacing="1" GridLines="None"
AutoGenerateColumns="False" OnRowCommand="gvReport_RowCommand" CssClass="mGrid" PagerStyle-CssClass="pgr" OnRowDataBound="gvReport_RowDataBound" >

<HeaderStyle CssClass="TTHeader"/>
<Columns>

<asp:TemplateField HeaderText="Year" ItemStyle-CssClass="TTRow" ControlStyle-CssClass="tablebluelink" ControlStyle-Width="55px">
<ItemTemplate >
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Eval("YR") %>'/>
<a href="#top"><asp:LinkButton ID="Linkbtn" runat="server" Text='<%# Eval("Year") %>' CommandName="lnkDate" OnClientClick="setFunc();" ></asp:LinkButton></a>




</ItemTemplate>
</asp:TemplateField>

<%-- <asp:BoundField DataField="YR" Visible="false" >--%>

<asp:BoundField DataField="Existing_Companies" HeaderText="Existing Companies">
<ItemStyle CssClass="TTRow_right"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="New_Companies" HeaderText="New Companies">
<ItemStyle CssClass="TTRow_right"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Total_Rs" HeaderText="Total">
<ItemStyle CssClass="TTRow_right"></ItemStyle>
</asp:BoundField>

<asp:BoundField DataField="Total_USD" HeaderText="Total USD">
<ItemStyle CssClass="TTRow_right"></ItemStyle>
</asp:BoundField>

</Columns>
</asp:GridView>
</td></tr>
</table>
</div>


<!-------2 nd grid ------------->
<br />
<br />
<asp:Label ID="lbl_year" onfocus='alert("Hey! I got the focus")' runat="server" Text="Label" Visible="false" Font-Bold="true"></asp:Label>

<br />
<a name="top"></a>
<td valign="top" colspan="3" height="42">
<div id="div2">
<table id="tabel2" width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#d6d6d6">
<asp:GridView ID="gvYearwise" runat="server" CellPadding="4" CellSpacing="1" GridLines="None"
AutoGenerateColumns="False" width="100%" CssClass="mGrid" PagerStyle-CssClass="pgr">
<HeaderStyle CssClass="TTHeader"/>
<Columns>

<%--<asp:TemplateField HeaderText="Col1" ItemStyle-CssClass="TTRow" ControlStyle-CssClass="tablebluelink">
<ItemTemplate >
<asp:LinkButton ID="Linkbtn" runat="server" Text='<%# Eval("Year") %>' CommandName="AddToCart" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" ></asp:LinkButton>
</ItemTemplate> </asp:TemplateField>--%>

<asp:BoundField DataField="Month" HeaderText="Month">
<ItemStyle CssClass="TTRow" Width="50px"></ItemStyle>
</asp:BoundField>

<asp:BoundField DataField="ExistingCompanies" HeaderText="ExistingCompanies">
<ItemStyle CssClass="TTRow_right"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="NewCompanies" HeaderText="NewCompanies">
<ItemStyle CssClass="TTRow_right"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="TotalRs" HeaderText="Total">
<ItemStyle CssClass="TTRow_right"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="TotalUSD" HeaderText="TotalUSD">
<ItemStyle CssClass="TTRow_right"></ItemStyle>
</asp:BoundField>



</Columns>
</asp:GridView>

</td></tr>

</table>
</div>





</div>
</div>
</div>
</div>
</asp:Content>





Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
Just use like this.....

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="top">
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:BoundField DataField="hi" DataFormatString="hi" />
<asp:BoundField DataField="bye" DataFormatString="bye" />
<asp:BoundField DataField="Hi" HeaderText="Hi" SortExpression="Hi" />
</Columns>
</asp:GridView>
<a href="#up">LinkButton</a>
</div>
<div>
<br />
<br />
</div>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<div id="up">
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>

</div>
</form>
</body>
</html>


G. S.
.Net Developer

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lalitha86 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
my link button is inside the GRID 1


<asp:TemplateField HeaderText="Year" ItemStyle-CssClass="TTRow" ControlStyle-CssClass="tablebluelink" ControlStyle-Width="55px">
<ItemTemplate >
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Eval("YR") %>'/>
<a href="#top"><asp:LinkButton ID="Linkbtn" runat="server" Text='<%# Eval("Year") %>' CommandName="lnkDate" OnClientClick="setFunc();" ></asp:LinkButton></a>




</ItemTemplate>
</asp:TemplateField>

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
Then you have to write this LinkButton inside the GridView like.....

<EmptyDataTemplate>

<a href="#up">LinkButton</a>
</EmptyDataTemplate>


G. S.
.Net Developer

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lalitha86 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
tried but not working


Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
But in my case its working.....okk at first remove the asp tag from the link button like

Remove this....
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>


and add only

<a href="#up">LinkButton</a>


G. S.
.Net Developer

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vikash on: 8/15/2012 [Member] Starter | Points: 25

Up
0
Down
plz tell me where to place the following in gridview

<EmptyDataTemplate>

<a href="#up">LinkButton</a>

</EmptyDataTemplate>

Regards,
Vikash Pathak

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response