Hello,
I am using the grid in card view and have data loading in the item template. I also have two link buttons in the template. Everything loads fine and pages OK. However I am trying to get to the click event of the link buttons so that when the user clicks on one of the link buttons I get a hidden field value which I use as a querystring parameter to take the user to a more detailed page.
I got it working on the first page but when I try to go to the next page in the grid. I get an error.
I am created a command name for the link butotns and have them in the grids Item_Command event. I am not sure if I am going about this the right way.
What am I doing wrong here?
I am using the grid in card view and have data loading in the item template. I also have two link buttons in the template. Everything loads fine and pages OK. However I am trying to get to the click event of the link buttons so that when the user clicks on one of the link buttons I get a hidden field value which I use as a querystring parameter to take the user to a more detailed page.
I got it working on the first page but when I try to go to the next page in the grid. I get an error.
I am created a command name for the link butotns and have them in the grids Item_Command event. I am not sure if I am going about this the right way.
What am I doing wrong here?
<div style="margin-left: auto; margin-right: auto; margin-top: 50px; width: 800px"> <telerik:RadGrid ID="RadGrid1" ShowGroupPanel="True" DataSourceID="SqlDataSource1" AllowPaging="True" runat="server" Width="800px" Height="800px" GridLines="None" PageSize="5" ShowHeader="false" BackColor="AliceBlue" BorderColor="Red" EnableEmbeddedSkins="true" Skin="Sitefinity"> <HeaderContextMenu> </HeaderContextMenu> <MasterTableView TableLayout="Fixed"> <ItemTemplate> <div style="float: left; margin-left: 10px; margin-top: 15px; width: 750px"> <div style="float: left; margin-bottom: 5px; font-size: 1.0em; font-weight: bold; width: 700px"> <asp:LinkButton ID="lnkTitle" runat="server" ForeColor="Blue" CommandName="Title" Font-Size="1.4em" Text='<%# Eval("Title")%>'> </asp:LinkButton> <asp:HiddenField ID="hdfId" runat="server" Value='<%# Eval("Id") %>' /> </div> <br /> <div style="float: left; width: 98%; color: Green"> <%# Eval("City")%>, <%# Eval("State")%>. - Posted: <%# Eval("PostedDate")%></div> <br /> <div style="float: left"> <%# Eval("Column1")%> <div> <asp:LinkButton ID="lnkMoreInfo" runat="server" CommandName="MoreInfo" ForeColor="Blue" Text="more info..."></asp:LinkButton> </div> </div> </div> </ItemTemplate> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"> </RowIndicatorColumn> <EditFormSettings> </EditFormSettings> <AlternatingItemStyle BackColor="White" /> <PagerStyle Mode="NextPrev" /> </MasterTableView> <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Wrap="True" /> <ClientSettings AllowDragToGroup="false"> <Scrolling AllowScroll="true" UseStaticHeaders="true" /> </ClientSettings> <FilterMenu EnableImageSprites="False"> </FilterMenu> </telerik:RadGrid> <br /> <br /> <asp:Label ID="lblMsg" runat="server" ForeColor="Red" /> <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="jobs_GridDataDisplay_Select" runat="server" SelectCommandType="StoredProcedure"> </asp:SqlDataSource>protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { //Find required controls in the grid. //Job Id. HiddenField hdfJobId = e.Item.FindControl("hdfId") as HiddenField; //Job title link button. LinkButton lnkTitle = e.Item.FindControl("lnkTitle") as LinkButton; //More info link button. LinkButton lnkMoreInfo = e.Item.FindControl("lnkMoreInfo") as LinkButton; if (lnkTitle.CommandName == "Title") { //Redirect to job details page. RedirectToJobDetails(hdfId.Value.ToString()); } if (lnkMoreInfo.CommandName == "MoreInfo") { //Redirect to job details page. RedirectToJobDetails(hdfJobId.Value.ToString()); } } private void RedirectToDetailsPage(string Id) { //Redirection path. string url = "~/pages/content/details.aspx?"; //Create the querystring parameter and encrypt. url += "id=" + Server.UrlEncode(DataEncryption.QueryStringEncrypt(Id)); Response.Redirect(url); }