开发者

Assign Label.Text from code behind

开发者 https://www.devze.com 2023-01-16 07:05 出处:网络
I have a label in aspx page. I am trying to assign text to that label according to my search criteria. My problem is if i put that label (lblMsge) insideI am unable to assign the text from code behind

I have a label in aspx page. I am trying to assign text to that label according to my search criteria. My problem is if i put that label (lblMsge) inside I am unable to assign the text from code behind. if i put that label outside the tr its working fine but the display is not proper. Please see the Image. I tried by putting that label in div tags also. But still no luck Can any one help me. Here is my code.

<tr id="trResults" visible="false" style="height: 700px;" runat="server">
                    <td valign="top" style="width: 100%;" align="center">
                        <table cellpadding="0" cellspacing="6" align="center" width="98%">
                            <tr>
                                <td align="center">
                                    <asp:Label ID="lblMsge" runat="server" Font-Bold="True" Font-Size="10pt" BackColor="Yellow"
                                        ForeColor="Black"></asp:Label>
                                    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                                    </telerik:RadAjaxManager>
                                    <div style="width: 98%; height: 600px; overflow: auto; overflow-y: hidden">
 开发者_运维知识库                                       <telerik:RadGrid ID="gvPjtMnt" runat="server">

                                        </telerik:RadGrid>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>


            if (gvPjtMnt.Items.Count <= 0)
        {
            lblMsge.Text = "No records found, please change the search criteria and try again.";
        }
        else
        {
            trResults.Visible = true;
            ScriptManager.RegisterClientScriptBlock(this.upRes, this.GetType(), "RecCount", "document.getElementById('ctl00_PagePlaceholder_gvPjtMnt_ctl00_ctl02_ctl00_lblTotRecCount').innerHTML='" + ds.Tables[0].Rows.Count + "'", true);
        }


First, are you sure a Label is the correct control to use? Labels are intended to semantically specify a.. well.. Label for another control. If you are not tying a Label to a control, chances are you are not using Labels as they are intended.

You most likely want to use a Literal control.

Second, your sample code doesn't make much sense, nor does your description. Are you actually putting your source code in with your aspx? Can you explain further what you mean by "Unable to assign"?

0

精彩评论

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