Click here to Skip to main content
15,888,610 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: IIS 6 to IIS 7 not working with unmanaged code Pin
Member 1302000829-Nov-17 6:25
Member 1302000829-Nov-17 6:25 
QuestionProblem With Radion Button List Pin
ais076-Jul-09 20:08
ais076-Jul-09 20:08 
AnswerRe: Problem With Radion Button List Pin
r a m e s h6-Jul-09 22:38
r a m e s h6-Jul-09 22:38 
QuestionAbout Web Service Pin
Deepak the Cool6-Jul-09 19:48
Deepak the Cool6-Jul-09 19:48 
AnswerRe: About Web Service Pin
N a v a n e e t h6-Jul-09 20:14
N a v a n e e t h6-Jul-09 20:14 
GeneralRe: About Web Service Pin
Deepak the Cool6-Jul-09 20:52
Deepak the Cool6-Jul-09 20:52 
Questionhow can i reset list box selected index after button click event in asp.net? Pin
anish27patel6-Jul-09 19:44
anish27patel6-Jul-09 19:44 
QuestionDeleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified. Pin
haleemasher6-Jul-09 19:38
haleemasher6-Jul-09 19:38 
hi plz help
when i click a delete link in gridview it show error after refreshing it it delete the row "Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified."
where my code in asp.net and C# is like that
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="RecordID" DataSourceID="SqlDataSource1" 
        
        style="top: 272px; left: 269px; position: absolute; height: 133px; width: 527px; z-index: 1" 
        onrowdeleting="Delete">
    <Columns>
        <asp:BoundField DataField="RecordID" HeaderText="RecordID" 
            InsertVisible="False" ReadOnly="True" SortExpression="RecordID" />
        <asp:BoundField DataField="CouponTypeID" HeaderText="CouponType" 
            SortExpression="CouponTypeID" />
        <asp:BoundField DataField="TransactionDate" HeaderText="Date" 
            SortExpression="TransactionDate" />
        <asp:BoundField DataField="TransactionTypeID" HeaderText="TransactionType" 
            SortExpression="TransactionTypeID" />
        <asp:BoundField DataField="Description" HeaderText="Description" 
            SortExpression="Description" />
        <asp:BoundField DataField="CafeMenu" HeaderText="Menu" 
            SortExpression="CafeMenu" />
        <asp:BoundField DataField="SerialStart" HeaderText="Start" 
            SortExpression="SerialStart" />
        <asp:BoundField DataField="SerialEnd" HeaderText="End" 
            SortExpression="SerialEnd" />
        <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
        <asp:TemplateField HeaderText="Delete">
        <ItemTemplate>
        <span onclick="return confirm('Are you sure to Delete the record?')">
        <asp:LinkButton   runat="server" ID="lnkDelete" CommandName="Delete" Text="Delete"  >
        </asp:LinkButton>
        </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<asp:Label ID="ErrorMessage" runat="server" 
        style="position:absolute; top: 645px; left: 282px; width: 682px; color: #FF9933; font-style: italic;" 
        Font-Bold="True" ForeColor="#003E3E"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:Coupon ManagementConnectionString10 %>" 
    SelectCommand="SELECT [RecordID], [CouponTypeID], [TransactionDate], [TransactionTypeID], [Description], [CafeMenu], [SerialStart], [SerialEnd], [Price] FROM [CouponTransaction]">
</asp:SqlDataSource>


</asp:Content>

and C# code is
protected void Delete(object sender, GridViewDeleteEventArgs e)
    {
        try
        {

            cnx.Open();
            SqlCommand mySqlDelete = new SqlCommand("delete from CouponTransaction where RecordID = @recordId", cnx);
            mySqlDelete.CommandType = CommandType.Text;
            mySqlDelete.Parameters.Add("@recordId", SqlDbType.Int).Value = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
            mySqlDelete.ExecuteNonQuery();
            ErrorMessage.Text = " Row Deleted Successfully";
            cnx.Close();
        }
        catch (Exception ex)
        {
            ErrorMessage.Text = ex.Message;
        }
}

AnswerRe: Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified. Pin
Abhijit Jana6-Jul-09 20:09
professionalAbhijit Jana6-Jul-09 20:09 
GeneralRe: Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified. Pin
haleemasher6-Jul-09 20:33
haleemasher6-Jul-09 20:33 
GeneralRe: Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified. Pin
J4amieC6-Jul-09 23:43
J4amieC6-Jul-09 23:43 
AnswerRe: Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified. Pin
Licky Nguyen22-Jul-09 1:02
Licky Nguyen22-Jul-09 1:02 
QuestionAnchror tag probelm Pin
indian1436-Jul-09 19:17
indian1436-Jul-09 19:17 
Questiondynamically added checkbox doesn't fire the event. Pin
prasadbuddhika6-Jul-09 19:06
prasadbuddhika6-Jul-09 19:06 
AnswerRe: dynamically added checkbox doesn't fire the event. Pin
N a v a n e e t h6-Jul-09 20:21
N a v a n e e t h6-Jul-09 20:21 
Questiondetect bluetooth device Pin
nithydurai6-Jul-09 19:04
nithydurai6-Jul-09 19:04 
AnswerRe: detect bluetooth device Pin
Abhijit Jana6-Jul-09 19:10
professionalAbhijit Jana6-Jul-09 19:10 
QuestionS/MIME Emails Pin
g00fyman6-Jul-09 18:37
g00fyman6-Jul-09 18:37 
QuestionIIS7 with ASP.NET + Response.OutputStream.Write does not work in IE7 and IE8 Pin
kent856-Jul-09 15:46
kent856-Jul-09 15:46 
Questionbuttonfield, onclick (change text) Pin
mark_me6-Jul-09 13:22
mark_me6-Jul-09 13:22 
Questionhelp upload file problem Pin
my30name6-Jul-09 11:43
my30name6-Jul-09 11:43 
Questionhow can I create custom dropdownlist ( inherited from standard dropdownlist) with 4 default items? Pin
mehran.asg6-Jul-09 8:38
mehran.asg6-Jul-09 8:38 
AnswerRe: how can I create custom dropdownlist ( inherited from standard dropdownlist) with 4 default items? Pin
Manas Bhardwaj6-Jul-09 10:23
professionalManas Bhardwaj6-Jul-09 10:23 
GeneralRe: how can I create custom dropdownlist ( inherited from standard dropdownlist) with 4 default items? Pin
mehran.asg6-Jul-09 19:08
mehran.asg6-Jul-09 19:08 
GeneralRe: how can I create custom dropdownlist ( inherited from standard dropdownlist) with 4 default items? Pin
mehran.asg6-Jul-09 19:09
mehran.asg6-Jul-09 19:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.