|
hello amigos.
I have a Gridview and i want to connect to the my database (by wizard)and i want to enable Delete but GenerateInsertUpdateDelete option in the AdvancedSqlGenerationOption window is disabled.
who know why?
|
|
|
|
|
1] It's requirement of one of my project that i need to store a HTML Code which contains various controls in SQL Server Database and retrieve it as a HTML page,so that all controls on the page get rendered properly.
2] How to store Website Template in SQL Database
|
|
|
|
|
It sounds like you are trying to write a CRM system, there are free ones available on the Internet, you might want to check these out as writing these is much harder than it looks on face-value.
To answer your question directly, you just store the HTML as you would any text. If you want to programatically add stuff into the template, you'll need to provide placeholders to insert into. e.g.
<html>
<head>
<title>
The title of this page is {{title}}
</title>
<head>
</thml>
Then you just perform a text susbstition. You can put the results of this into an ASP.NET literal control (though the above template wouldn't be valid as the literal will be inside a form in which you'd be declaring a html document), or write to the repsonse stream
Note that you'll difficulty "injecting" ASP.NET controls to the form like this, though the HTML controls will be fine. You might want to look at ASP.NET MVC, if you have time, it is much more suited to this type of work.
|
|
|
|
|
+5
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I want some basic knowledge to create a website
|
|
|
|
|
|
|
Those articles helped me a couple of years ago.
David
|
|
|
|
|
Then you came to the right place. There are many articles on this site that you can go through and even filter down to what you are specifically looking for. And if you get stuck on something specific you can ask in the QA section.
Good luck to you.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
hello
I have a problem.please help me.
my program works without ScriptManagerProxy correctly in the page of product.ascx but with it doesn't work! why?
the source of program is available in below:
example
|
|
|
|
|
Please remember that we all do our work entirely voluntary, and most of us do not download zip-Files posted in a Forum because of the risk that it may include a virus.
If you post the code you are referring to (in the appropriate <pre> - tags) you are going to receive a broader feedback, and it is more likely that someone can help you with your issue.
Veni, vidi, caecus | Everything summarizes to Assembly code
|
|
|
|
|
OK!
the .aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register src="admin/productions.ascx" tagname="Product" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<uc1:Product ID="Product1" runat="server" />
</div>
</form>
</body>
</html>
the .ascx page
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Productions.ascx.cs" Inherits="Admin_Productions" %>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Import Namespace="System.Configuration"%>
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div align="center">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="CategoryName"
DataValueField="CategoryID">
</asp:DropDownList><br /><br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [tbl_ProductCategory]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" BackColor="White"
BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4"
DataKeyNames="ProductionID" DataSourceID="SqlDataSource2" >
<EmptyDataTemplate>
در این دسته بندی داده ای نیست
</EmptyDataTemplate>
<RowStyle BackColor="White" ForeColor="#003399" />
<Columns>
<asp:CommandField CancelText="انصراف" DeleteText="حذف" EditText="ویرایش"
HeaderText="عملیات" ShowDeleteButton="True" ShowEditButton="True"
UpdateText="بروز رسانی" />
<asp:BoundField DataField="ProductionID" HeaderText="ای دی محصول"
InsertVisible="False" ReadOnly="True" SortExpression="ProductionID" />
<asp:TemplateField HeaderText="ای دی دسته بندی محصول"
SortExpression="ProductionCategoryID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("ProductionCategoryID") %>' Enabled="false"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server"
Text='<%# Bind("ProductionCategoryID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ProductionName" HeaderText="نام محصول"
SortExpression="ProductionName" />
<asp:BoundField DataField="Cast" HeaderText="قیمت به تومان"
SortExpression="Cast" />
<%----%>
<asp:TemplateField HeaderText="عکس یا فیلم" SortExpression="ImageFilm">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ImageFilm") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="75px" Width="75px" ImageUrl='<%# Bind("ImageFilm") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Comments" HeaderText="توضیحات"
SortExpression="Comments" />
<asp:BoundField DataField="Stock" HeaderText="موجودی" SortExpression="Stock" />
</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
</asp:GridView>
<br />
<br />
<div dir="rtl">
<%----%> <br />
<table class="style1">
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="ای دی دسته بندی محصول"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="CategoryName"
DataValueField="CategoryID">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="نام محصول"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtProName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtProName" Display="Dynamic"
ErrorMessage="نام محصول را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="قیمت"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtCast" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtCast" Display="Dynamic"
ErrorMessage="قیمت را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="عکس یا فیلم"></asp:Label>
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text="توضیحات"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtComment" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtComment" Display="Dynamic"
ErrorMessage="توضیحات را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" runat="server" Text="موجودی"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtStock" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtStock" Display="Dynamic"
ErrorMessage="موجودی را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
</table>
<br />
<%----%>
<%----%>
<asp:Button ID="btnAddProductions" runat="server" Text="اضافه کردن محصولات"
onclick="btnAddProductions_Click" />
<asp:Label ID="lblResult" runat="server" ForeColor="Red"></asp:Label>
<br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
</div>
</div>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [tbl_Production] WHERE [ProductionID] = @original_ProductionID AND [ProductionCategoryID] = @original_ProductionCategoryID AND [ProductionName] = @original_ProductionName AND [Cast] = @original_Cast AND [ImageFilm] = @original_ImageFilm AND [Comments] = @original_Comments AND [Stock] = @original_Stock"
InsertCommand="INSERT INTO [tbl_Production] ([ProductionCategoryID], [ProductionName], [Cast], [ImageFilm], [Comments], [Stock]) VALUES (@ProductionCategoryID, @ProductionName, <a href="/Members/cast">@Cast</a> @ImageFilm, @Comments, <a href="/Members/stock">@Stock</a>"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [tbl_Production] WHERE ([ProductionCategoryID] = @ProductionCategoryID)"
UpdateCommand="UPDATE [tbl_Production] SET [ProductionCategoryID] = @ProductionCategoryID, [ProductionName] = @ProductionName, [Cast] = <a href="/Members/cast">@Cast</a> [ImageFilm] = @ImageFilm, [Comments] = @Comments, [Stock] = <a href="/Members/stock">@Stock</a>WHERE [ProductionID] = @original_ProductionID AND [ProductionCategoryID] = @original_ProductionCategoryID AND [ProductionName] = @original_ProductionName AND [Cast] = @original_Cast AND [ImageFilm] = @original_ImageFilm AND [Comments] = @original_Comments AND [Stock] = @original_Stock">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="ProductionCategoryID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="original_ProductionID" Type="Int32" />
<asp:Parameter Name="original_ProductionCategoryID" Type="Int32" />
<asp:Parameter Name="original_ProductionName" Type="String" />
<asp:Parameter Name="original_Cast" Type="Decimal" />
<asp:Parameter Name="original_ImageFilm" Type="String" />
<asp:Parameter Name="original_Comments" Type="String" />
<asp:Parameter Name="original_Stock" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ProductionCategoryID" Type="Int32"/>
<asp:Parameter Name="ProductionName" Type="String" />
<asp:Parameter Name="Cast" Type="Decimal" />
<asp:Parameter Name="ImageFilm" Type="String" />
<asp:Parameter Name="Comments" Type="String" />
<asp:Parameter Name="Stock" Type="Int32" />
<asp:Parameter Name="original_ProductionID" Type="Int32" />
<asp:Parameter Name="original_ProductionCategoryID" Type="Int32" />
<asp:Parameter Name="original_ProductionName" Type="String" />
<asp:Parameter Name="original_Cast" Type="Decimal" />
<asp:Parameter Name="original_ImageFilm" Type="String" />
<asp:Parameter Name="original_Comments" Type="String" />
<asp:Parameter Name="original_Stock" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ProductionCategoryID" Type="Int32" />
<asp:Parameter Name="ProductionName" Type="String" Size="100"/>
<asp:Parameter Name="Cast" Type="Decimal" />
<asp:Parameter Name="ImageFilm" Type="String" Size="100"/>
<asp:Parameter Name="Comments" Type="String" />
<asp:Parameter Name="Stock" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
the .ascx.cs page
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
public partial class Admin_Productions : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAddProductions_Click(object sender, EventArgs e)
{
bool fileOK = false;
string[] allow = { ".jpg", ".jpeg", ".gif", ".bmp", ".png" };
string fileExtension = Path.GetExtension(FileUpload1.FileName).ToLower().Trim();
if (FileUpload1.HasFile)
{
for (int i = 0; i < allow.Length; i++)
{
if (fileExtension == allow[i] && FileUpload1.FileBytes.Length < 1048576)
{
fileOK = true;
}
}
}
if (fileOK==true)
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/images/"+FileUpload1.FileName));
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
string query = "insert into tbl_production values (@proCatId,@proName,@proCast,@proPic,@proComment,@proStock)";
SqlCommand cm = new SqlCommand(query, cn);
cm.Parameters.AddWithValue("proCatId", DropDownList2.SelectedValue);
cm.Parameters.AddWithValue("proName", txtProName.Text.Trim().ToLower());
cm.Parameters.AddWithValue("proCast", txtCast.Text.Trim());
cm.Parameters.AddWithValue("proPic", "~/images/"+FileUpload1.FileName.Trim().ToLower());
cm.Parameters.AddWithValue("proComment", txtComment.Text);
cm.Parameters.AddWithValue("proStock", txtStock.Text);
cn.Open();
cm.ExecuteNonQuery();
lblResult.Text = "registered";
cn.Close();
}
else
{
lblResult.Text = "incorrect";
}
}
}
|
|
|
|
|
If you are expecting people to help you with this then you need to explain exactly what the problem is and where in all that code it occurs. Just dumping your code and saying "it does not work" is not enough.
Veni, vidi, abiit domum
|
|
|
|
|
OK but i said that what problem is.
I have three page.
The default page and one user control and third ,code behind of the user control that i have put it in previous post.
My program work correctly without the ScriptManagerProxy (without Ajax) but with it doesn't work.(in the .ascx page).
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%--------my code--------%>
</ContentTemplate>
</asp:UpdatePanel>
If i remove the Ajax tag that have put above,my program hasn't any problem BUT if put it ,doesn't work properly.
now do you help me?
modified 2-Jan-14 5:59am.
|
|
|
|
|
Sorry, I'm not an ASP expert. I was merely suggesting that you need to provide full details of your problem if you want people to help you. Don't assume that people can guess what you are doing.
Veni, vidi, abiit domum
|
|
|
|
|
hello again
see,my problem exactly is that my program without putting the ScriptManagerProxy hasn't any problem and works properly.but with it doesn't work.
"doesn't work" is in other word,not that my program has an error,no,only works bad.(i haven't a syntax error while have a runtime error only and only for the ScriptManagerProxy tag )
for more explanations:
in the code below,if we haven't ScriptManagerProxy tag in the page,we can to enter the values in the fiels and press the button to sends the values.but if we put ScriptManagerProxy tag in the page,the program isn't able to send the values because says FileUpload1.HasFile is false (fileupload1 is empty)then the if condition isn't true therefore my Query doesn't run.i hope to explain properly.
<table class="style1">
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="ای دی دسته بندی محصول"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="CategoryName"
DataValueField="CategoryID">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="نام محصول"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtProName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtProName" Display="Dynamic"
ErrorMessage="نام محصول را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="قیمت"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtCast" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtCast" Display="Dynamic"
ErrorMessage="قیمت را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="عکس یا فیلم"></asp:Label>
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text="توضیحات"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtComment" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtComment" Display="Dynamic"
ErrorMessage="توضیحات را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" runat="server" Text="موجودی"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtStock" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtStock" Display="Dynamic"
ErrorMessage="موجودی را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
</table>
<br />
<!---------------------->
<!------------------------------------------------------------------------>
<asp:Button ID="btnAddProductions" runat="server" Text="add productions" onclick="btnAddProductions_Click" />
<!------------------------------------------------------------------------>
<asp:Label ID="lblResult" runat="server" ForeColor="Red"></asp:Label>
<br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
in this code behind file in below,the running of the query is dependent to correctness fileOK variable.
therefore first must FileUpload1.HasFile be true.
when the program runs,and i fill the fields and press the button,the program jumps on "else" and runs
lblResult.Text="the format of the image isn't true";
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
public partial class Admin_Productions : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAddProductions_Click(object sender, EventArgs e)
{
bool fileOK = false;
string[] allow = { ".jpg", ".jpeg", ".gif", ".bmp", ".png" };
string fileExtension = Path.GetExtension(FileUpload1.FileName).ToLower().Trim();
if (FileUpload1.HasFile)
{
for (int i = 0; i < allow.Length; i++)
{
if (fileExtension == allow[i] && FileUpload1.FileBytes.Length < 1048576)
{
fileOK = true;
}
}
}
if (fileOK==true)
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/images/"+FileUpload1.FileName));
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
string query = "insert into tbl_production values (@proCatId,@proName,@proCast,@proPic,@proComment,@proStock)";
SqlCommand cm = new SqlCommand(query, cn);
cm.Parameters.AddWithValue("proCatId", DropDownList2.SelectedValue);
cm.Parameters.AddWithValue("proName", txtProName.Text.Trim().ToLower());
cm.Parameters.AddWithValue("proCast", txtCast.Text.Trim());
cm.Parameters.AddWithValue("proPic", "~/images/"+FileUpload1.FileName.Trim().ToLower());
cm.Parameters.AddWithValue("proComment", txtComment.Text);
cm.Parameters.AddWithValue("proStock", txtStock.Text);
cn.Open();
cm.ExecuteNonQuery();
lblResult.Text = "the new production is registered";
cn.Close();
}
else
{
lblResult.Text = "the format of the image isn't true";
}
}
}
modified 2-Jan-14 8:22am.
|
|
|
|
|
How to find curses movement in text box
Suppose i have written like 45hgy
now by command button i want to insert betwenn 45h and gy
like 45hanygy
How
Thanks
|
|
|
|
|
Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
hello.. i'm having a problem while binding the values to drop down chosen i'm not getting a search box to enter the text for auto search..please, kindly reply as soon as possible
|
|
|
|
|
Explain your question clearly and post your code snippet
To learn all there is to know. I know I'll be disappointed one day, but I've made a good start, and the eventual disappointment is likely to be brief.
-Roger Wright
Never doubt that a small group of thoughtful, committed people can change the world. Indeed, it is the only thing that ever has.-Margaret Mead
|
|
|
|
|
How can we help?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Hello friends, thanks for your help so far. Please, I developed a chatroom and is working fine. But the challenge here is that:
I placed the repeater control inside a panel control and set the panel scrollbars to auto. But, the panel couldn't scroll to bottom. Please, how can I make the panel control to always scroll to bottom so that users can see the last message? Please render any help. Cheers!!!
|
|
|
|
|
how to define scafolding in mvc?
|
|
|
|
|