如何设置ASPxNavBar组控件

时间:2011-06-21 13:25:04

标签: c# asp.net visual-studio-2010 devexpress

我的项目中有一个ASPxNavBar控件。它有一些具有contenttemplate的NavBarGroup。

                                                                                                                                                                              Hasta Tc Kimlik No:                                                                                                                                                                                                                                                                                                                                                                                            广告:                                                                                                       

                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Soyad:
                            </td>
                            <td>
                                <dx:ASPxTextBox ID="txtHastaSoyad" runat="server" Width="170px">
                                 </dx:ASPxTextBox>
                            </td>
                        </tr>
                      </table>
                 </ContentTemplate>
            </dx:NavBarGroup>
         ......................

我想获取NavBarGroup并设置其控件的值。

            Hasta hasta = new Hasta(Session["hasta_id"].To<int>());
            NavBarGroup hastaGrup = nbDiyalizBildirim.Groups.FindByName("hasta");
            ((ASPxTextBox)hastaGrup.FindControl("txtHastaTCkimlikNo")).Text = hasta.M_TcKimlikNo;
            ((ASPxTextBox)hastaGrup.FindControl("txtHastaAd")).Text = hasta.M_Adi;
            ((ASPxTextBox)hastaGrup.FindControl("txtHastaSoyad")).Text = hasta.M_Soyadi;

我如何设定他们的价值?

提前致谢。

1 个答案:

答案 0 :(得分:0)

以下代码在这里工作正常:

protected void ASPxNavBar1_PreRender(object sender, EventArgs e) {
        ASPxNavBar navBar = sender as ASPxNavBar;
        ASPxTextBox txtBox = navBar.Groups[0].FindControl("txtBox") as ASPxTextBox;
        txtBox.Text = "some test string";
    }

这是aspx标记:

<dx:ASPxNavBar ID="ASPxNavBar1" runat="server" OnPreRender="ASPxNavBar1_PreRender">
    <Groups>
        <dx:NavBarGroup>
            <ContentTemplate>
                <dx:ASPxTextBox ID="txtBox" runat="server"></dx:ASPxTextBox>
            </ContentTemplate>
        </dx:NavBarGroup>
    </Groups>
</dx:ASPxNavBar>