PDA

View Full Version : سوال: قرار دادن treeview در آپدیت پنل



zareei_ta
شنبه 19 آذر 1390, 16:19 عصر
من در داخل آپدیت پنل یک کنترلtreeview قرار دادم که در باز کردن زیر درخت ها هر بار صفحه لود نشه. با این کار زیر درخت ها سریع باز میشوند اما با کلیک هر زیر درخت یک سری اطلاعات باید در گرید نشون داده بشه ، که با این کار این اطلاعات الان در گرید نمیاد.
لطفا کمک کنید


<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
<ContentTemplate>

<asp:TreeView ID="TreeView1" runat="server" style="position: relative;top:25px"
LineImagesFolder="CSS/TreeLineImages" CssClass="TreeView"
ImageSet="Simple2" onselectednodechanged="TreeView1_SelectedNodeChanged1"
Font-Size="Larger" ontreenodeexpanded="TreeView1_TreeNodeExpanded" >
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle CssClass="HoverTreeNode " ForeColor="White"
Font-Underline="false" />
<SelectedNodeStyle CssClass="SelectedTreeNode" Font-Underline="false"
ForeColor="White" HorizontalPadding="0px" VerticalPadding="0px"
BackColor="White" />
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black"
HorizontalPadding="0px" NodeSpacing="0px" VerticalPadding="0px" />
</asp:TreeView>
</ContentTemplate>

</asp:UpdatePanel>

hamid_shrk
شنبه 19 آذر 1390, 16:30 عصر
تو کدتون کلیکتون چی نوشتید که چیزی نشون نمیده؟؟

zareei_ta
شنبه 19 آذر 1390, 16:37 عصر
یک سری اطلاعات را از دیتابیس بخونه و در گرید نشون بده

کد زیر را نوشتم


protected void TreeView1_SelectedNodeChanged1(object sender, EventArgs e)
{

string val = TreeView1.SelectedValue.ToString();
SqlDataSource2.SelectCommand = "SELECT id, GroupId, JobsId, SoftwareName, SoftwarePrice, ImageName, Description, GroupName, JobsTitle FROM Softwares WHERE (GroupId=" + val + ") ORDER BY SoftwareName";
TreeView1.ExpandDepth = 0;
try
{
GridView2.DataBind();
}
catch { }
}

hamid_shrk
شنبه 19 آذر 1390, 16:43 عصر
گرید و SqlDataSource تون رو هم باید داخل آپدیت پنل بذارید.

zareei_ta
شنبه 19 آذر 1390, 17:20 عصر
من کد زیر را نوشتم اما بعضی موقع کار میکنه و بعضی موقع کار نمیکنه


<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" >
<ContentTemplate>

<asp:TreeView ID="TreeView1" runat="server" style="position: relative;top:25px"
LineImagesFolder="CSS/TreeLineImages" CssClass="TreeView"
ImageSet="Simple2" onselectednodechanged="TreeView1_SelectedNodeChanged1"
Font-Size="Larger" ontreenodeexpanded="TreeView1_TreeNodeExpanded" >
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle CssClass="HoverTreeNode " ForeColor="White"
Font-Underline="false" />
<SelectedNodeStyle CssClass="SelectedTreeNode" Font-Underline="false"
ForeColor="White" HorizontalPadding="0px" VerticalPadding="0px"
BackColor="White" />
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black"
HorizontalPadding="0px" NodeSpacing="0px" VerticalPadding="0px" />
</asp:TreeView>
<div id="contentDiv" style="position:absolute;right:180px; width:500px; min-height:900px;direction:ltr;top:60px;z-index:100">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
PageSize="5" CellPadding="4"
DataKeyNames="id,Description" DataSourceID="SqlDataSource2" ForeColor="#333333"
GridLines="None" Width="500px" style="height:200px; margin-right: 0px;"
AllowPaging="True" BorderStyle="Solid" BorderColor="Gray"
onselectedindexchanged="GridView2_SelectedIndexChanged"
onrowcommand="GridView2_RowCommand" DataMember="DefaultView"
OnRowDataBound="GridView2_RowDataBound" Height="160px" onpageindexchanging="GridView2_PageIndexChanging">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="Description" HeaderText="متن" HtmlEncode="False"
HtmlEncodeFormatString="False" ItemStyle-Width="300px" ItemStyle-CssClass="hideGridColumn" HeaderStyle-CssClass="hideGridColumn">
<HeaderStyle CssClass="hideGridColumn"></HeaderStyle>
<ItemStyle Width="300px" ></ItemStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="لیست شغل و نرم افزار های هر گروه" SortExpression="SoftwareName" ItemStyle-Width="450px" HeaderStyle-Font-Size="Small" >
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("SoftwareName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<table border="1" style="width: 100%; height: 100%">
<tr>
<td style="background-image: url(Images/back.gif); height: 12px">
</td>
</tr>
<tr>
<td>
<table style="width: 100%; height: 100%">
<tr>
<td rowspan="3" style="width: 92px">
<asp:Image ID="ImgSoft" runat="server" Height="77px" ImageUrl='<%# Eval("ImageName") %>'
Width="92px" /></td>
<td align="center" style="width: 30%">
<asp:Label ID="lblSoftware" runat="server" Font-Bold="True" Font-Size="Small"
Text='<%# Bind("SoftwareName") %>'></asp:Label></td>
<td style="width: 70%" align="right">
<asp:Label ID="Label2" runat="server" ForeColor="Maroon" Text=":نرم افزار" Width="80px"></asp:Label></td>
</tr>
<tr>
<td align="center" style="width: 85%">
<asp:Label ID="lblJob" runat="server" Font-Size="Small"
Text='<%# Bind("JobsTitle") %>'></asp:Label></td>
<td align="right" style="width:80px">
<asp:Label ID="Label3" runat="server" ForeColor="Maroon" Text=":نام شغل"
style="top:140px; right:0px;"></asp:Label></td>
</tr>
<tr>
<td align="right" style="width: 85%">
<table style="width: 100%; height: 100%">
<tr>
<td align="center">
<asp:Label ID="lblPrice" runat="server" Font-Size="Small"
Text='<%# Eval("SoftwarePrice") %>'></asp:Label></td>
</tr>
</table>
</td>
<td style="width: 15%" align="right">
<asp:Label ID="Label4" runat="server" ForeColor="Maroon" Text=":قیمت"></asp:Label></td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
<HeaderStyle Font-Size="Small"></HeaderStyle>
<ItemStyle Width="500px"></ItemStyle>
</asp:TemplateField>
<asp:CommandField ButtonType="Image" HeaderText="انتخاب"
SelectImageUrl="~/Images/opened.gif" ShowSelectButton="True"
ItemStyle-Width="30px"
Visible="False" >
<HeaderStyle CssClass="hideGridColumn"></HeaderStyle>
<ItemStyle Width="30px" HorizontalAlign="Right"></ItemStyle>
</asp:CommandField>
<asp:BoundField DataField="id" HeaderText="کد کالا"
HeaderStyle-CssClass="hideGridColumn" ItemStyle-CssClass="hideGridColumn">
<HeaderStyle CssClass="hideGridColumn"></HeaderStyle>
</asp:BoundField>

</Columns>
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle Font-Bold="True" ForeColor="#333333" BackColor="#E2DED6" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:JobsSoftwareSite %>"
SelectCommand="SELECT * FROM [Softwares] WHERE ([GroupId] = @GroupId) ORDER BY [SoftwareName]">
<SelectParameters>
<asp:ControlParameter ControlID="TreeView1" Name="GroupName"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GridView2" />
</Triggers>

</asp:UpdatePanel>

zareei_ta
یک شنبه 20 آذر 1390, 11:16 صبح
من سایتم را اپلود کردم و ورژن ان را به Asp 4 تغییر دادم اما کد اپدیت پنلم کار نمیکنه در حالی که در لوکال کار می کنه. مشکل از کجا میتونه باشه

hamid_shrk
یک شنبه 20 آذر 1390, 11:36 صبح
من سایتم را اپلود کردم و ورژن ان را به Asp 4 تغییر دادم اما کد اپدیت پنلم کار نمیکنه در حالی که در لوکال کار می کنه. مشکل از کجا میتونه باشه
فکر نمیکنم ربطی به ورژن دات نت داشته باشه ، آدرس سایت یا کدتون رو بذارید