G
Guest
Hello,
How do i confirm before delete from the datagrid?
I did like this. But getting error... "Object Reference not set to an
instance of object"
<asp:datagrid id="dgbrand" Runat="server" Font-Size="12px" Font-Name="arial"
BorderColor="SteelBlue" OnEditCommand="editMode" OnUpdateCommand="doUpdate"
OnCancelCommand="cancelEdit" DataKeyField="brand_code"
AutoGenerateColumns="False" Width="400px" Font-Names="arial"
OnDeleteCommand="doDelete"> <AlternatingItemStyle
BackColor="#CCCCCC"></AlternatingItemStyle> <HeaderStyle Font-Bold="True"
BackColor="Salmon"></HeaderStyle>
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="CAN" EditText="Edit"></asp:EditCommandColumn>
<asp:BoundColumn DataField="brand_code" ReadOnly="True" HeaderText="Brand
Code">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="brand_name"
HeaderText="Description"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="cmddel" Runat="server" Font-Underline="True"
ForeColor="#0000ff" CommandName="Delete">Del</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn></Columns> </asp:datagrid>
Private Sub dgbrand_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgbrand.ItemDataBound
Dim mybut As LinkButton
mybut = e.Item.FindControl("cmddel")
mybut.Attributes.Add("onclick", "return confirm('Are you sure to
delete?')")
End Sub
And, i placed the controls manually in the table tag.
When i rebuild the project, automatically some unnecessary table is adding
in VS.NET that changes my actual alignment. How can i stop this?
Thanx in advance
How do i confirm before delete from the datagrid?
I did like this. But getting error... "Object Reference not set to an
instance of object"
<asp:datagrid id="dgbrand" Runat="server" Font-Size="12px" Font-Name="arial"
BorderColor="SteelBlue" OnEditCommand="editMode" OnUpdateCommand="doUpdate"
OnCancelCommand="cancelEdit" DataKeyField="brand_code"
AutoGenerateColumns="False" Width="400px" Font-Names="arial"
OnDeleteCommand="doDelete"> <AlternatingItemStyle
BackColor="#CCCCCC"></AlternatingItemStyle> <HeaderStyle Font-Bold="True"
BackColor="Salmon"></HeaderStyle>
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="CAN" EditText="Edit"></asp:EditCommandColumn>
<asp:BoundColumn DataField="brand_code" ReadOnly="True" HeaderText="Brand
Code">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="brand_name"
HeaderText="Description"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="cmddel" Runat="server" Font-Underline="True"
ForeColor="#0000ff" CommandName="Delete">Del</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn></Columns> </asp:datagrid>
Private Sub dgbrand_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgbrand.ItemDataBound
Dim mybut As LinkButton
mybut = e.Item.FindControl("cmddel")
mybut.Attributes.Add("onclick", "return confirm('Are you sure to
delete?')")
End Sub
And, i placed the controls manually in the table tag.
When i rebuild the project, automatically some unnecessary table is adding
in VS.NET that changes my actual alignment. How can i stop this?
Thanx in advance