开发者

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 click开发者_StackOverflowing 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜