Link to home
Start Free TrialLog in
Avatar of KavyaVS
KavyaVS

asked on

How to pass parameters to java script function from OnClient Click(from the Link button in DataGrid)

Hi,
I am trying  to pass parameters to java script function from OnClient Click(from the Link button in DataGrid).It is giving me the error in the grid generation itself.The error is
Server tag is not well formed.

Please see the DataGrid source and JavaScript function.

<ASP:DATAGRID id="DGrid" runat="server"  ShowFooter="False"
                        AutoGenerateColumns="False" BorderWidth="2" cellspacing="0" cellpadding="3" HeaderStyle-CssClass="TableHeaders"
                        EnableViewState="True" >
             
                        <Columns>
                <asp:TemplateColumn HeaderText="Number">
     
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkNumber" runat="server" CausesValidation="false" OnClientClick="openmodaldialog2(document.getElementById(" + '<%#("lnkNumber.ClientID") %>' + ");" Text='<%# DataBinder.Eval(Container, "DataItem.ID") %>' readonly="True"></asp:LinkButton>
                         
                         </ItemTemplate>
                        <HeaderStyle Width="200px" />
                 </asp:TemplateColumn>
                              
                              <ASP:BoundColumn HeaderStyle-Width="50px" HeaderText="Name" DataField="Name" readonly="True" />
                              <ASP:BoundColumn HeaderStyle-Width="100px" HeaderText="Address" DataField="Address""
                                    readonly="True" />
                              <ASP:BoundColumn HeaderStyle-Width="100px" HeaderText="State" DataField="State"
                                    readonly="True" />
                              <ASP:BoundColumn HeaderStyle-Width="100px" HeaderText="Zip" DataField="Zip"
                                     readonly="True" />
                        </Columns>
                  </ASP:DATAGRID>

 function openmodaldialog2(Num)
     {
         myPopUp2 = window.showModalDialog("Page1.aspx", "", "dialogHeight: 350px;dialogWidth: 650px;status:no;")
       
        return false;
    }
if there is no OnClienClick() event the Grid is populating fine.
Any suggestion for passing the parameres from OnClientClick event in the DataGrid.

Thanks.
SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Kumaraswamy R
Kumaraswamy R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KavyaVS
KavyaVS

ASKER

Thanks