Hi nedash,
Here i have created sample. Refer the below code.
SQL
CREATE TABLE nedash167600
(
Id INT IDENTITY,
PCode NVARCHAR(50),
OrderType NVARCHAR(50),
Format NVARCHAR(50),
PType NVARCHAR(50),
PSectionName NVARCHAR(50),
PName NVARCHAR(50),
PriceT NVARCHAR(50)
)
GO
CREATE PROC Order_Confirm
@PCode NVARCHAR(50),
@OrderType NVARCHAR(50),
@Format NVARCHAR(50),
@PType NVARCHAR(50),
@PSectionName NVARCHAR(50),
@PName NVARCHAR(50),
@PriceT NVARCHAR(50)
AS
BEGIN
INSERT INTO nedash167600
VALUES(@PCode,@OrderType,@Format,@PType,@PSectionName,@PName,@PriceT)
END
GO
SELECT * FROM nedash167600
GO
HTML
<asp:GridView runat="server" ID="gvOrders" EmptyDataText="هنوز محصولی را برای خرید انتخاب ننموده اید."
CssClass="gridorder" GridLines="Vertical" AutoGenerateColumns="false" DataKeyNames="Id"
RowStyle-BorderColor="#cccccc" RowStyle-BorderStyle="Solid" RowStyle-BorderWidth="1px"
BorderStyle="Solid" BorderWidth="1px" AlternatingRowStyle-BackColor="#fbfbfb"
HeaderStyle-CssClass="gridviewH" AlternatingRowStyle-BorderStyle="Solid" BorderColor="#cccccc"
EmptyDataRowStyle-CssClass="grivorder" EmptyDataRowStyle-ForeColor="#FF0066"
EmptyDataRowStyle-BorderStyle="NotSet" Font-Names="behtop_Yekan">
<Columns>
<asp:TemplateField HeaderText="Id" Visible="false">
<ItemTemplate>
<asp:Label ID="lblId" runat="server" Text='<%# Eval("Id")%>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="76px" ItemStyle-VerticalAlign="Middle" ItemStyle-HorizontalAlign="Center"
HeaderText="کد" ItemStyle-Height="40" HeaderStyle-CssClass="Hgrid">
<ItemTemplate>
<asp:Label ID="LblPcode" runat="server" CssClass="lblcode" Text='<%#toPersianNumber(Eval("PCode").ToString())%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="765px" ItemStyle-VerticalAlign="Middle" ItemStyle-HorizontalAlign="Center"
HeaderText="توضیحات محصول">
<ItemTemplate>
<div id="Griddes">
<div id="lgformat">
<asp:Label ID="LblOrderType" runat="server" CssClass="kharidP" Text='<%# Eval("OrderType")%>'></asp:Label>
<div id="lgformatf1">
<asp:Label ID="LblFormat" runat="server" CssClass="lblGquality4" Text='<%# Eval("Format")%>'></asp:Label>
<asp:Label ID="Label8" runat="server" CssClass="lblGquality3">فرمت:</asp:Label>
</div>
</div>
<div id="lblnameGO">
<asp:Label ID="LblPtype" runat="server" CssClass="Lgtype" Text='<%# Eval("PType")%>'></asp:Label>
<asp:Label ID="Label6" runat="server" CssClass="Lgtype1">نوع محصول:</asp:Label>
</div>
</div>
<div id="Griddes1" runat="server" class="Griddes1" visible='<%#Eval("PType").ToString() == "فيلم مستند" ? true : false %>'>
<div id="lblnameGO2">
<asp:Label ID="LblPSectionName" runat="server" CssClass="Lgtype2" Text='<%# Eval("PSectionName")%>'></asp:Label>
<asp:Label ID="Label4" runat="server" CssClass="Lgtype3">نام قسمت:</asp:Label>
</div>
<div id="lblnameGO1">
<asp:Label ID="LblName" runat="server" Text='<%# Eval("PName")%>' CssClass="Lgname"></asp:Label>
<asp:Label ID="Label7" runat="server" CssClass="Lgname1">نام محصول:</asp:Label>
</div>
</div>
<div id="Griddes3" runat="server" class="Griddes3" visible='<%#Eval("PType").ToString() == "فيلم مستند" ? false : true %>'>
<div id="lblnameGO5">
<asp:Label ID="LblPName" runat="server" Text='<%# Eval("PName")%>' CssClass="Lgname1S"></asp:Label>
<asp:Label ID="Label14" runat="server" CssClass="Lgname1">نام محصول:</asp:Label>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="132px" ItemStyle-VerticalAlign="Middle" ItemStyle-HorizontalAlign="Center"
HeaderText="قیمت">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" CssClass="toman1">تومان</asp:Label>
<asp:Label ID="LblPriceT" runat="server" CssClass="lblpriceS" Text='<%#toPersianNumber(Convert.ToDouble(Eval("PriceT")).ToString("N0"))%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:LinkButton Text="LBsabt" OnClick="LBsabt_Click" runat="server" />
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[]
{
new DataColumn("Id", typeof(int)),
new DataColumn("PCode", typeof(string)),
new DataColumn("OrderType",typeof(string)),
new DataColumn("Format",typeof(string)),
new DataColumn("PType",typeof(string)),
new DataColumn("PSectionName",typeof(string)),
new DataColumn("PName",typeof(string)),
new DataColumn("PriceT",typeof(string))
});
dt.Rows.Add(1, "123", "OrderType1", "Format1", "PType1", "PSectionName1", "PName1", "1200");
dt.Rows.Add(2, "453", "OrderType2", "Format2", "PType2", "PSectionName2", "PName2", "2100");
dt.Rows.Add(3, "751", "OrderType3", "Format3", "PType3", "PSectionName3", "PName3", "3531");
dt.Rows.Add(4, "698", "OrderType4", "Format4", "PType4", "PSectionName4", "PName4", "4764");
gvOrders.DataSource = dt;
gvOrders.DataBind();
}
}
public string toPersianNumber(string input)
{
string[] persian = new string[10] { "۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹" };
for (int j = 0; j < persian.Length; j++)
{
input = input.Replace(j.ToString(), persian[j]);
}
char[] charArray = input.ToCharArray();
Array.Reverse(charArray);
return new string(charArray);
}
protected void LBsabt_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in gvOrders.Rows)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString))
{
using (SqlCommand _cmd = new SqlCommand("Order_Confirm", conn))
{
_cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
string Pcode = (row.FindControl("LblPcode") as Label).Text.Trim();
string OrderType = (row.FindControl("LblOrderType") as Label).Text.Trim();
string format = (row.FindControl("LblFormat") as Label).Text.Trim();
string Ptype = (row.FindControl("LblPtype") as Label).Text.Trim();
string PSectionName = (row.FindControl("LblPSectionName") as Label).Text.Trim();
string PName = (row.FindControl("LblName") as Label).Text.Trim();
string PriceT = (row.FindControl("LblPriceT") as Label).Text.Trim();
_cmd.Parameters.AddWithValue("@PCode", Pcode);
_cmd.Parameters.AddWithValue("@PType", Ptype);
_cmd.Parameters.AddWithValue("@PSectionName", PSectionName);
_cmd.Parameters.AddWithValue("@PName", PName);
_cmd.Parameters.AddWithValue("@OrderType", OrderType);
_cmd.Parameters.AddWithValue("@Format", format);
_cmd.Parameters.AddWithValue("@PriceT", PriceT);
_cmd.ExecuteNonQuery();
}
conn.Close();
}
}
}
Screenshot