• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 944
  • Last Modified:

concatenate in side listview eval

 onclick="OpenWnd('" & '<%#Eval("row_id") %>' & "')"

Open in new window

i want the result to be
onlick="openwnd(123);"

how would i do that
0
StewSupport
Asked:
StewSupport
  • 2
1 Solution
 
Rajar AhmedConsultantCommented:
Try this ,

<asp:LinkButton D="DeleteButton" runat="server" CommandName="Delete" OnClientClick='<%# CreateConfirmation(Eval("row_id")) %>'>Delete</asp:LinkButton>

Public Function CreateConfirmation(ByVal Username As String) As String
    Return String.Format("return confirm('Are you sure you want to delete {0}?');", Username)
End Function

Open in new window

0
 
Rajar AhmedConsultantCommented:
try this Small demo ,
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DgBound.aspx.vb" Inherits="Vb_DgBound" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script>
        function openwnd(idClicked) {

            alert("You Clicked " + idClicked);
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div style="width:85%;text-align:left" >
            <asp:Button ID="ShowActiveOrAll" runat="server" Text="Active Only"  OnClick="ShowActiveOrAll_Click" /></div><br />

    <asp:GridView ID="dgBound" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:BoundField DataField="id" HeaderText="ID"></asp:BoundField>
           
                <asp:TemplateField  HeaderText="Click Me" ItemStyle-Width="1px">
     <ItemTemplate >
         
          <a  id="A1" runat="server" onclick='<%# CreateConfirmation(Eval("id"))%>'>Click Me</a>
     </ItemTemplate>
     
     </asp:TemplateField>

        </Columns>

    </asp:GridView>
    </div>
    </form>
</body>
</html>
Imports System.Data

Partial Class Vb_DgBound
    Inherits System.Web.UI.Page

    
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim ds As DataSet = getDataSet()
        If Not IsPostBack Then
            dgBound.DataSource = ds
            dgBound.DataBind()
        End If
    End Sub
  
    Public Function CreateConfirmation(ByVal Username As String) As String
        Return String.Format("return openwnd({0});", Username)
    End Function

#Region "Temp ds"
    Public Shared Function getDataSet() As DataSet
        Dim ds As New DataSet
        Dim dt As DataTable
        Dim dr As DataRow
        Dim idCoulumn As DataColumn
        Dim nameCoulumn As DataColumn
        Dim i As Integer

        dt = New DataTable()
        idCoulumn = New DataColumn("ID", Type.GetType("System.Int32"))
        nameCoulumn = New DataColumn("Status", Type.GetType("System.String"))

        dt.Columns.Add(idCoulumn)
        dt.Columns.Add(nameCoulumn)

        dr = dt.NewRow()
        dr("ID") = 1
        dr("Status") = "Active"
        dt.Rows.Add(dr)

        dr = dt.NewRow()
        dr("ID") = 2
        dr("Status") = "Not Active"
        dt.Rows.Add(dr)

        dr = dt.NewRow()
        dr("ID") = 3
        dr("Status") = "Active"
        dt.Rows.Add(dr)


        dr = dt.NewRow()
        dr("ID") = 4
        dr("Status") = "Not Active"
        dt.Rows.Add(dr)

        dr = dt.NewRow()
        dr("ID") = 5
        dr("Status") = "Active"
        dt.Rows.Add(dr)


        dr = dt.NewRow()
        dr("ID") = 6
        dr("Status") = "Not Active"
        dt.Rows.Add(dr)
        dr = dt.NewRow()
        dr("ID") = 7
        dr("Status") = "Active"
        dt.Rows.Add(dr)


        dr = dt.NewRow()
        dr("ID") = 8
        dr("Status") = "Not Active"
        dt.Rows.Add(dr)

        ds.Tables.Add(dt)
        Return ds
    End Function
#End Region

   End Class

Open in new window

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now