Click here to Skip to main content
15,905,068 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: SCHEDULER IN VISUAL STUDIOS Pin
Vincent Maverick Durano20-Mar-18 17:57
professionalVincent Maverick Durano20-Mar-18 17:57 
GeneralRe: SCHEDULER IN VISUAL STUDIOS Pin
Faisal721-Mar-18 3:00
Faisal721-Mar-18 3:00 
GeneralRe: SCHEDULER IN VISUAL STUDIOS Pin
Charlie brown 7113-Apr-18 0:35
Charlie brown 7113-Apr-18 0:35 
QuestionDomain driven design pattern and onion architecture is same or different Pin
Mou_kol13-Mar-18 22:05
Mou_kol13-Mar-18 22:05 
AnswerRe: Domain driven design pattern and onion architecture is same or different Pin
Bohdan Stupak20-Mar-18 4:48
professionalBohdan Stupak20-Mar-18 4:48 
AnswerRe: Domain driven design pattern and onion architecture is same or different Pin
anmolgoranga22-Mar-18 1:41
anmolgoranga22-Mar-18 1:41 
QuestionDifference between Open ID and OAuth Pin
Mou_kol13-Mar-18 4:14
Mou_kol13-Mar-18 4:14 
AnswerRe: Difference between Open ID and OAuth Pin
Vincent Maverick Durano18-Mar-18 21:39
professionalVincent Maverick Durano18-Mar-18 21:39 
GeneralRe: Difference between Open ID and OAuth Pin
Mou_kol19-Mar-18 23:20
Mou_kol19-Mar-18 23:20 
GeneralRe: Difference between Open ID and OAuth Pin
Vincent Maverick Durano20-Mar-18 17:17
professionalVincent Maverick Durano20-Mar-18 17:17 
QuestionArchitecture similar to asp.net boilerplate Pin
Charlie brown 71112-Mar-18 20:47
Charlie brown 71112-Mar-18 20:47 
QuestionProcess master detail JSON with WCF Pin
Priyanka Kale9-Mar-18 0:08
Priyanka Kale9-Mar-18 0:08 
QuestionData Access In Models & Repositories Pin
Priyanka Kale7-Mar-18 22:42
Priyanka Kale7-Mar-18 22:42 
AnswerRe: Data Access In Models & Repositories Pin
Richard MacCutchan7-Mar-18 23:09
mveRichard MacCutchan7-Mar-18 23:09 
AnswerRe: Data Access In Models & Repositories Pin
Nagaraj Muthuchamy12-Mar-18 22:57
professionalNagaraj Muthuchamy12-Mar-18 22:57 
QuestionAn error occurred while receiving the HTTP response to https://localhost:44301/XXXXXXX.svc. Pin
indian1437-Mar-18 13:36
indian1437-Mar-18 13:36 
SuggestionRe: An error occurred while receiving the HTTP response to https://localhost:44301/XXXXXXX.svc. Pin
Richard Deeming8-Mar-18 9:06
mveRichard Deeming8-Mar-18 9:06 
QuestionUnable to cast object of type 'System.Web.UI.WebControls.TemplateField' to type 'System.Web.UI.WebControls.CommandField' Pin
samflex7-Mar-18 6:49
samflex7-Mar-18 6:49 
I have a markup page that was using CommandField delete button. This was later replaced with regular button control.

Code:

   <table>
      <tr>
        <td>
          <asp:gridview ID="Gridview1" RowStyle-Wrap="false" gridlines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="Gridview1_RowDeleting">
            <Columns>
            <asp:BoundField DataField="RowNumber" Visible="false" HeaderText="Row Number" />
            <asp:TemplateField HeaderText="Name">
             <headerstyle horizontalalign="Left" />
                <ItemTemplate>
                    <asp:TextBox ID="txtsourcename" placeholder="Name...(e.g, Jane Doe)" runat="server" style="width:375px;" AutoPostBack="true" class="form-control textClass" OnTextChanged="txtsourcename_TextChanged"></asp:TextBox><br />
                    <asp:CheckBox ID="grid1Details" ClientIDMode="Static" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="Grid1CheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Address">
            <ItemStyle HorizontalAlign="Left"></ItemStyle>
                <ItemTemplate>
                    <asp:TextBox ID="txtsourceaddress" placeholder="Address..." runat="server" style="width:375px;" class="form-control textClass"></asp:TextBox><br /><br />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="">
                <ItemTemplate>
                 <asp:Button ID="ButtonAdd" runat="server" Text="Add" 
                        onclick="ButtonAdd_Click" CssClass="grvAddButton" /><br /><br /><br>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="">
                <ItemTemplate>
                 <asp:Button ID="sourceDelete" runat="server" Text="Delete" CommandName="Delete"
                         CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br />
                </ItemTemplate>
            </asp:TemplateField> 
<%--           <asp:CommandField ShowDeleteButton="True"><ControlStyle CssClass="grvDelButton" /></asp:CommandField>--%>
            </Columns>
          </asp:gridview>
        </td>
     </tr>
   </table>


The delete button is used to delete any additional / unwanted rows created in dynamically generated row in GridView.

Since the commandField delete button was replaced, the VB the engineers the delete action is now throwing an error:
Unable to cast object of type 'System.Web.UI.WebControls.TemplateField' to type 'System.Web.UI.WebControls.CommandField'

Does anyone know how to modify this to reflect the button control ID used in markup instead of CommandField?

PHP
Protected Sub GrvSource_RowDataBound(sender As Object, e As GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.Header Then
            If e.Row.RowIndex = -1 Then
                DirectCast(DirectCast(e.Row.Cells(4), DataControlFieldCell).ContainingField, CommandField).ShowDeleteButton = False
            End If
        Else
            If Convert.ToInt32(ViewState("rowIndex" & 0)) = e.Row.RowIndex Then
                DirectCast(DirectCast(e.Row.Cells(4), DataControlFieldCell).ContainingField, CommandField).ShowDeleteButton = True
            End If
        End If
    End Sub



Thank in advance
AnswerRe: Unable to cast object of type 'System.Web.UI.WebControls.TemplateField' to type 'System.Web.UI.WebControls.CommandField' Pin
Richard Deeming7-Mar-18 8:40
mveRichard Deeming7-Mar-18 8:40 
GeneralRe: Unable to cast object of type 'System.Web.UI.WebControls.TemplateField' to type 'System.Web.UI.WebControls.CommandField' Pin
samflex7-Mar-18 9:32
samflex7-Mar-18 9:32 
Questioncreating organisational charts Pin
Member 137048122-Mar-18 0:08
Member 137048122-Mar-18 0:08 
AnswerRe: creating organisational charts Pin
David Mujica2-Mar-18 10:43
David Mujica2-Mar-18 10:43 
QuestionWeb API: Can we generate token without using identity Pin
Mou_kol27-Feb-18 22:53
Mou_kol27-Feb-18 22:53 
AnswerRe: Web API: Can we generate token without using identity Pin
Nathan Minier5-Mar-18 2:00
professionalNathan Minier5-Mar-18 2:00 
GeneralRe: Web API: Can we generate token without using identity Pin
Mou_kol5-Mar-18 21:13
Mou_kol5-Mar-18 21:13 

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.