简体   繁体   中英

Javascript and ASP.NET

In my case I am retrieving some data from the backend.

In that one particular column in the gridview should be hidden. It should not be shown on the screen. In case if is use visible="false" the data is not showing in when clicking the event the text box how to do this please help me.

Source code:

<asp:BoundField DataField="GLAC_NAME" HeaderText="A/cNo">
    <ItemStyle Width="200px" />
</asp:BoundField>

This particular column I have to hide should not shown to the user

Code begin:

protected void GridLedger_RowDataBound(object sender, GridViewRowEventArgs e)
{
        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onMouseDown", "var str = document.getElementById('" + e.Row.ClientID + "').cells[1].innerText; document.getElementById('"+TextBox1.ClientID+"').value = str;");   

            }
        }
        catch (System.Exception ex)
        {
            throw ex;
        }
}

Here is the code begin in this what I should mention in cell value

When you use visible=false then it won't render the html to the browser so your javascript won't work. You should try setting a css attribute to hide it instead: display:none;

I never use "OnMouseDown". "onclick" is the standard because it doesn't override the right mouse button.

On the web page that is created, press "view source" and see if the javascript even exists (Maybe there are no "DataRows" in your datagrid?)

next - Does cells[1] exist?

I'm not sure but maybe you're supposed to call texbox.text and not textbox.value. Should check that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM