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
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() + "');");
}
}
}