Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BusDetails.aspx.cs" Inherits="BusDetails"
%> <!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"> <script
type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="js/jquery-latest.js" type="text/javascript"></script> <script
type="text/javascript"> var setid, busfrom, busto, dateofjou, google; var arr
= []; function getData(val, val1) { // $('#dialog').load('cata_view.php?id=' + val);
setid = document.getElementById("lblqq").value; if (setid == "") { setid = val1;
} else { setid = setid + "," + val1; } alert(google); document.getElementById("lblqq").value
= setid; $('#dialog').load('testing.aspx?bookcount=' + val + '&bno=' + setid); alert(setid);
ShowDialog(true); } function ShowDialog(modal) { $("#overlay").show(); $("#dialog").fadeIn(300);
if (modal) { $("#overlay").unbind("click"); } else { $("#overlay").click(function
(e) { HideDialog(); }); } } function HideDialog() { $("#overlay").hide(); $("#dialog").fadeOut(300);
} <form id="form1" runat="server"> <asp:HiddenField ID="hdnfld" runat="server"
/>
<table width="75%">
    <tr>
        <td>
            <table align="center" width="100%" cellpadding="0" cellspacing="0" style="background: #183574;&lt;br mode=" hold=" /&gt;                &lt; br" mode="">
                <tr>
                    <td width="16%" align="center">
                        &lt;asp:Label ID="Label3" runat="server" Text="Travels"&gt;
                    </td>
                    <td width="16%" align="center">
                        &lt;asp:Label ID="Label2" runat="server" Text="Travels"&gt;
                    </td>
                    <td width="16%" align="center" height="30px">
                        &lt;asp:Label ID="Label1" runat="server" Text="Bus Type"&gt;
                    </td>
                    <td align="center" width="15%">
                        &lt;asp:Label ID="Label4" runat="server" Text="Timings"&gt;
                    </td>
                    <td width="10%" align="center">
                        &lt;asp:Label ID="Label5" runat="server" Text="Duration"&gt;
                    </td>
                    <td width="22%" align="center">
                        &lt;asp:Label ID="Label6" runat="server" Text="Features"&gt;
                    </td>
                    <td width="10%" align="center">
                        &lt;asp:Label ID="Label7" runat="server" Text="Fare"&gt;
                    </td>
                    <td width="18.5%" align="center">
                        &lt;asp:Label ID="Label8" runat="server" Text="Avilability"&gt;
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table width="100%">
                <tr>
                    <td>
                        &lt;asp:DataList ID="dsgrid" runat="server" OnSelectedIndexChanged="dsgrid_SelectedIndexChanged"&gt;
                        <itemtemplate>
                                    <div style="width: 100%; float: left;">
                                        <div style="width: 100%; float: left;">
                                            <div style="float: left; width: 100%; border: solid 1px #ccc;">
                                                <h3 class="hd3">
                                                    <div style="float: left;">
                                                        <span id="budget11_exp_col" class="redirect-rt filter expnd" title="expand"></span>
                                                    </div>
                                                    <table>
                                                        <tr>
                                                            <td width="150px" align="center">
                                                                &lt;%# DataBinder.Eval(Container.DataItem, "bus_travaller")%&gt;
                                                                &lt;asp:Label ID="lblbusid" runat="server" Text=' &lt;%# DataBinder.Eval(Container.DataItem, "bus_id")%&gt;'&gt;
                                                            </td>
                                                            <td width="150px" align="center">
                                                                &lt;%# DataBinder.Eval(Container.DataItem, "bus_Type")%&gt;
                                                            </td>
                                                            <td width="120px" align="center">
                                                                &lt;%# DataBinder.Eval(Container.DataItem, "journey_start_time")%&gt;
                                                            </td>
                                                            <td width="150px" align="center">
                                                                &lt;%# DataBinder.Eval(Container.DataItem, "destination_reach_time")%&gt;
                                                            </td>
                                                            <td width="200px" align="center">
                                                                &lt;%# DataBinder.Eval(Container.DataItem, "bus_features")%&gt;
                                                            </td>
                                                            <td width="100px" align="center">
                                                                &lt;%# DataBinder.Eval(Container.DataItem, "fare")%&gt;
                                                            </td>
                                                            <td width="100px" align="center">
                                                                &lt;asp:Button ID="getset" runat="server" OnClick="getset_Click" Text='&lt;%# DataBinder.Eval(Container.DataItem, "Availability")%&gt;' /&gt;
                                                                &lt;asp:Label ID="busfrom" runat="server" Text='&lt;%# DataBinder.Eval(Container.DataItem, "Bus_from")%&gt;'&gt;
                                                            </td>
                                                            &lt;asp:LinkButton ID="lnk" runat="server" OnClientClick="javascript:getData(' &lt;%# DataBinder.Eval(Container.DataItem, "bus_id")%&gt;','&lt;%# DataBinder.Eval(Container.DataItem, "Availability")%&gt;');return false;"&gt;pop
                                                            </tr></table></h3></div></div></div></itemtemplate>
                    </td>
                </tr>
                <tr>
                    <td colspan="7">
                        &lt;div id="getdiv" runat="server"&gt;
                    </td>
                </tr>
            </table>
            <table align="center">
                <tr>
                    <td align="center">
                        &lt;asp:Button ID="lnkFirst" runat="server" Font-Bold="true" Text="&lt;&lt;" Height="31px"
                        Width="43px" /&gt;
                    </td>
                    <td>
                        &lt;asp:Button ID="lnkPrevious" runat="server" Font-Bold="true" Text="&lt;" Height="31px"
                        Width="43px" /&gt;
                    </td>
                    <td>
                        &lt;asp:Button ID="lnkNext" runat="server" Font-Bold="true" Text="&gt;" Height="31px"
                        Width="43px" OnClick="lnkNext_Click" /&gt;
                    </td>
                    <td>
                        &lt;asp:Button ID="lnkLast" runat="server" Font-Bold="true" Text="&gt;&gt;" Height="31px"
                        Width="43px" /&gt;
                    </td>
                    <td>
                        &lt;asp:TextBox ID="lblqq" runat="server"&gt;
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<div id="overlay" class="web_dialog_overlay">
</div>
<div id="dialog" class="web_dialog">
    yggiuguiuiuiyhiuyhuiyhuiyh
</div>
</form> </body> </html> I am passing the values Like <b><asp:LinkButton
    ID="lnk" runat="server" OnClientClick="javascript:getData(' <%# DataBinder.Eval(Container.DataItem,
    "bus_id")%>','<%# DataBinder.Eval(Container.DataItem, "Availability")%>');return
    false;">pop  </b>
But i am not geting that values onclientclick event.
 
Thank You
Posted 22-Jan-13 0:58am
Edited 22-Jan-13 3:27am
v4

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Can you use a anchor instead of link button? If you replace link button with an anchor you can bind the href tag to the getData function. The reason I suggest an anchor is because I couldn't find the HTML equivalent of link button to be type casted in server side code. Here's how you can do with anchor tag
 
 <asp:DataList runat="server" ID="ddl">
    <ItemTemplate>
    <div>
    
    <a id="lnkbutton" runat="server" href="javascript:void(0)"><%#DataBinder.Eval(Container.DataItem,"bus_features") %></a>
    </div>
    
    </ItemTemplate>
    
    </asp:DataList>
 
The server side code would be
 
Protected Sub ddl_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.DataListItemEventArgs) Handles ddl.ItemDataBound
       Try
           If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
               Dim drv As DataRowView = TryCast(e.Item.DataItem, DataRowView)
               Dim lnkBtn As HtmlAnchor = TryCast(e.Item.FindControlR("lnkButton"), HtmlAnchor)
               lnkBtn.Attributes.Add("href", "javascript:getData('" & drv("bus_id").ToString() & "','" & drv("Availability").ToString() & "');")
           End If
       Catch ex As Exception
           ' Throw
       End Try
   End Sub
 
C# code behind
 
protected void ddl_ItemDataBound(object sender, DataListItemEventArgs  e) 
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                DataRowView drv = (DataRowView)e.Item.DataItem;
                HtmlAnchor lnkbtn = (HtmlAnchor)e.Item.FindControl("lnkButton");
                if (lnkbtn != null)
                {
                    lnkbtn.Attributes.Add("href", "javascript:getData('" + drv["bus_id"].ToString() + "','" + drv["Availability"].ToString() + "');");                
                }            
            }
 
        }
  Permalink  
v5
Comments
vakativamsi at 23-Jan-13 3:40am
   
Thank You Ruchin ...this code is helpful to me .Basical i dont know the VB,Buy i will undersand and Get the Answer Thankyou once agine
Ruchin Munjal at 23-Jan-13 16:01pm
   
I have added C# code as well.. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CHill60 320
1 Sarvesh Kumar Gupta 238
2 Sergey Alexandrovich Kryukov 173
3 OriginalGriff 163
4 DamithSL 153


Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid