M
Marianne
Hi,
I am using a GridView, no sql or objectdatasource. In the rowdeleting
event, the event arg e.Values.Count = 0, and the sender.Rows = 0, yet I have
3 rows and multiple non-key datavalues. Why would these values be 0?
thanks for any help,
Marianne
event code:
protected void CoBrandsGrid_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
// Delete the row in the database
int cobrandID =
Convert.ToInt32(CoBrandsGrid.DataKeys[(int)e.RowIndex].Value);
string description = e.Values["Description"].ToString();
//string description = CoBrandsGrid.Rows[e.RowIndex].Cells[0].Text;
CobrandData.DeleteCobrand(cobrandID, description);
CoBrandsGrid.DataSource = CobrandData.LoadCobrands();
CoBrandsGrid.DataBind();
}
aspx code:
<asp:GridView
id="CoBrandsGrid"
autogeneratecolumns="False"
backcolor="White"
bordercolor="Transparent"
width="80%"
gridlines="None"
cellpadding="4"
cellspacing="2"
borderstyle="None"
DataKeyNames="CoBrandID"
EmptyDataText="No Cobrands have been created."
AlternatingRowStyle-BackColor="#E0E0E0"
OnRowDataBound="CoBrandsGrid_RowDataBound"
OnRowDeleting="CoBrandsGrid_RowDeleting"
EnableViewState="false"
runat="server" >
<headerstyle font-bold="True" horizontalalign="Center" forecolor="White"
cssclass="tableHeaderStyle"
backcolor="#660000"></headerstyle>
<footerstyle forecolor="Black" backcolor="#C6C3C6"></footerstyle>
<columns>
<asp:boundfield itemstyle-horizontalalign="Left" datafield="Description"
headertext="CoBrand Description"></asp:boundfield>
<asp:boundfield itemstyle-horizontalalign="Left" datafield="EnterDate"
headertext="Created Date"
dataformatstring="{0:MM/dd/yyyy}"></asp:boundfield>
<asp:boundfield itemstyle-horizontalalign="Center"
datafield=""></asp:boundfield>
<asp:boundfield itemstyle-horizontalalign="Center"
datafield=""></asp:boundfield>
<asp:CommandField
ButtonType="Link"
DeleteText="Delete"
ShowDeleteButton="true"
ControlStyle-CssClass="removeButton"
ItemStyle-HorizontalAlign="Right"
/>
</columns>
</asp:GridView>
I am using a GridView, no sql or objectdatasource. In the rowdeleting
event, the event arg e.Values.Count = 0, and the sender.Rows = 0, yet I have
3 rows and multiple non-key datavalues. Why would these values be 0?
thanks for any help,
Marianne
event code:
protected void CoBrandsGrid_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
// Delete the row in the database
int cobrandID =
Convert.ToInt32(CoBrandsGrid.DataKeys[(int)e.RowIndex].Value);
string description = e.Values["Description"].ToString();
//string description = CoBrandsGrid.Rows[e.RowIndex].Cells[0].Text;
CobrandData.DeleteCobrand(cobrandID, description);
CoBrandsGrid.DataSource = CobrandData.LoadCobrands();
CoBrandsGrid.DataBind();
}
aspx code:
<asp:GridView
id="CoBrandsGrid"
autogeneratecolumns="False"
backcolor="White"
bordercolor="Transparent"
width="80%"
gridlines="None"
cellpadding="4"
cellspacing="2"
borderstyle="None"
DataKeyNames="CoBrandID"
EmptyDataText="No Cobrands have been created."
AlternatingRowStyle-BackColor="#E0E0E0"
OnRowDataBound="CoBrandsGrid_RowDataBound"
OnRowDeleting="CoBrandsGrid_RowDeleting"
EnableViewState="false"
runat="server" >
<headerstyle font-bold="True" horizontalalign="Center" forecolor="White"
cssclass="tableHeaderStyle"
backcolor="#660000"></headerstyle>
<footerstyle forecolor="Black" backcolor="#C6C3C6"></footerstyle>
<columns>
<asp:boundfield itemstyle-horizontalalign="Left" datafield="Description"
headertext="CoBrand Description"></asp:boundfield>
<asp:boundfield itemstyle-horizontalalign="Left" datafield="EnterDate"
headertext="Created Date"
dataformatstring="{0:MM/dd/yyyy}"></asp:boundfield>
<asp:boundfield itemstyle-horizontalalign="Center"
datafield=""></asp:boundfield>
<asp:boundfield itemstyle-horizontalalign="Center"
datafield=""></asp:boundfield>
<asp:CommandField
ButtonType="Link"
DeleteText="Delete"
ShowDeleteButton="true"
ControlStyle-CssClass="removeButton"
ItemStyle-HorizontalAlign="Right"
/>
</columns>
</asp:GridView>