PDA

View Full Version : سوال: ساخت صفحه محصولات



khore_64
یک شنبه 06 اسفند 1391, 14:28 عصر
سلام
من کاملا مبتدی هستم و تازه شروع به کار کردم
یه پروژه آماده دارم و میخوام تغییراتی روش بدم
تقریبا همه ش درست هست فقط در بخش محصولات من میخوام که به صورت زیر نمایش بدم
100488

اما با توجه به کدها و استفاده از گرید ویو به این شکل نمایش داده میشود

100489

کدها html :


<table border="0" width="80%" align=center cellspacing=5px dir=rtl>
<tr>
<td align="center" valign="top">
<asp:Label ID="lblMessage" runat="server" ForeColor="#0055a6" Visible=false></asp:Label>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" CellPadding="4" ForeColor="#333333" GridLines="None" HorizontalAlign="Center" ShowHeader="False" Width="100%" OnRowDataBound="GridView2_RowDataBound" AllowPaging="True" PageSize="7">
<Columns>
<asp:TemplateField HeaderText="id" InsertVisible="False" SortExpression="id" Visible="False">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("id") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="prodname" SortExpression="prodname" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("prodname") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("prodname") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="description" SortExpression="description" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("description") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="codeunit" SortExpression="codeunit" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("codeunit") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("codeunit") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="price" SortExpression="price" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("price") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("price") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="enable" SortExpression="enable" Visible="False">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox3" runat="server" Checked='<%# Bind("enable") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox3" runat="server" Checked='<%# Bind("enable") %>' Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="general" SortExpression="general" Visible="False">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox5" runat="server" Checked='<%# Bind("general") %>' />
</EditItemTemplate>

</asp:TemplateField>
<asp:TemplateField HeaderText="imagefile" SortExpression="imagefile" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("imagefile") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("imagefile") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="catname" SortExpression="catname" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("catname") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Bind("catname") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="table">
<ItemTemplate>
<div align="center">
<div id="probox"><asp:Image ID="img" runat="server" Width="100px" /><br />
<div id="protitr">
Design: <asp:Label ID="lblName" runat="server" Font-Bold="True" ForeColor="#0000C0"></asp:Label>
</div>
<div id="promore"><asp:HyperLink ID="lnkMore" runat="server" ForeColor="#0000C0">more info</asp:HyperLink></div>
</div>

</div>

</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle/>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:WebConnectionString %>"
SelectCommand="GetProductList" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter ConvertEmptyStringToNull="False" Name="ProdName" Type="String" DefaultValue="" />
<asp:ControlParameter ControlID="lblCatIDs" ConvertEmptyStringToNull="False" Name="CatID"
PropertyName="Text" Type="String" />
<asp:Parameter DefaultValue="1" Name="Enable" Type="Int32" />
<asp:Parameter DefaultValue="-1" Name="IsNew" Type="Int32" />
<asp:Parameter DefaultValue="-1" Name="IsTop" Type="Int32" />
<asp:Parameter DefaultValue="-1" Name="General" Type="Int32" />
<asp:SessionParameter ConvertEmptyStringToNull="False" DefaultValue="-1" Name="MemID"
SessionField="MemID" Type="Int32" />
<asp:Parameter DefaultValue="0" Name="English" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td>

</tr>
</table>





public partial class website_catlist : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["catID"] == null)
{
Response.Redirect("products.aspx");
}
else
{
string strCatID = Request.QueryString["catID"].ToString();
lblCatName.Text = DB.coding.GetCategoryPath(int.Parse(strCatID));
lblCatIDs.Text = strCatID;
string strAllCats = DB.coding.GetAllChildList(int.Parse(strCatID), "1");
if (strAllCats != "") lblCatIDs.Text = strCatID + "," + strAllCats;

}
//if (GridView1.Rows.Count == 0)
//{
// Image1.Visible = true;
//}
//else
//{
// Image1.Visible = false;
//}
if (GridView2.Rows.Count == 0)
{
lblMessage.Text = "متاسفانه دراين گروه محصولي تعريف نشده است";
lblMessage.Visible = true;
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex != -1)
{
HyperLink lnkTitle = (HyperLink)e.Row.Cells[3].FindControl("lnk");
Label lbl1 = (Label)e.Row.Cells[1].Controls[1];
Label imgName = (Label)e.Row.Cells[2].Controls[1];
Label lblID = (Label)e.Row.Cells[0].Controls[1];
lnkTitle.Text = lbl1.Text;
lnkTitle.NavigateUrl = "catList.aspx?catID=" + lblID.Text;
}

}
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex != -1)
{
HyperLink lnk = (HyperLink)e.Row.FindControl("lnkMore");
Label lblName = (Label)e.Row.FindControl("lblName");
//Label lbldesc = (Label)e.Row.FindControl("lblDesc");
//Label lblTop = (Label)e.Row.FindControl("lblTop");
//Label lblNew = (Label)e.Row.FindControl("lblNew");
Image img = (Image)e.Row.FindControl("img");

Label ID = (Label)e.Row.Cells[0].Controls[1];
Label Name = (Label)e.Row.Cells[1].Controls[1];
//Label Desc = (Label)e.Row.Cells[2].Controls[1];
//CheckBox chkTop = (CheckBox)e.Row.Cells[5].Controls[1];
//CheckBox chkNew = (CheckBox)e.Row.Cells[6].Controls[1];
Label imgName = (Label)e.Row.Cells[7].Controls[1];

HyperLink lnkImgGallery = (HyperLink)e.Row.FindControl("lnkGallery");
//string strAlbumID = DB.Albums.GetProdAlbumID(ID.Text);
//if (strAlbumID != "-1")
//{
// lnkImgGallery.Visible = true;
// lnkImgGallery.NavigateUrl = "viewGallery.aspx?galleryID=" + strAlbumID;
//}

lnk.NavigateUrl = "viewProduct.aspx?id=" + ID.Text;

lblName.Text = Name.Text;
//lbldesc.Text = Desc.Text;
if (imgName.Text != "")
{
img.ImageUrl = "../images/prodimages/" + imgName.Text;
img.Visible = true;
}
else
{
img.Visible = false;
}
}
}
}

Mohammadvb6
یک شنبه 06 اسفند 1391, 15:42 عصر
به جای گرید ویو از رپیتر استفاده کنید . اگر هم در مورد ریپیتر اطلاعات می خواید : سرچ کنید

khore_64
یک شنبه 06 اسفند 1391, 16:16 عصر
مرسی .
یعنی دقیقا گرید ویو رو بردارم ریپیتر بزارم جاش؟
سرچ کردم زیاد چیزی دستگیرم نشد
میشه بیشتر راهنمایی کنید

aliblue
یک شنبه 06 اسفند 1391, 16:50 عصر
با Repeater فکر نکنم بشه. با Datalist میشه و باید خاصیت RepeatColumns را برابر 4 یا هر مقدار دیگر قرار دهید.

khore_64
یک شنبه 06 اسفند 1391, 22:27 عصر
میشه یه نمونه کد به من بدین
من هرچی میگردم نمیتونم درستش کنم

Mohammadvb6
دوشنبه 07 اسفند 1391, 11:54 صبح
http://barnamenevis.org/showthread.php?334122-%D9%88%D8%A7%DA%A9%D8%B4%DB%8C-%D8%B1%DA%A9%D9%88%D8%B1%D8%AF%D9%87%D8%A7-%D8%AF%D8%B1-%DA%86%D9%86%D8%AF%DB%8C%D9%86-%D8%B3%D8%AA%D9%88%D9%86-%D9%85%D8%A7%D9%86%D9%86%D8%AF-%D9%81%D8%B1%D9%88%D8%B4%DA%AF%D8%A7%D9%87%D9%87%D 8%A7&highlight=%D8%B1%DB%8C%D9%BE%DB%8C%D8%AA%D8%B1