ASP.NET GridView

P

Peter

ASP.NET 3.5

I have a Gridview which display just fine
I have Delete and Update Template on this GridView

When I click on the Delete button on the GridView the following event fires
RowDeleting(object sender, GridViewDeleteEventArgs e)

but when I try to retrieve the data from a cell inside the RowDeleting event

protected void gvEducation_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
string transactionID = gvEducation.Rows[e.RowIndex].Cells[4].Text;

this._dt.DeleteEducation(transactionID);
this.BindEducationGrid();
}

the transactionID is always blank, but on the screen it displays values
(each cell has some value), actually all of the Cells return blanks, but
display data.

What am I doing wrong?

Thank You

Peter
 
P

Peter

Yes I am calling BindEducationGrid() every time, currently there are only 3
records in the table and Rows.Count shows 3 rows but cells return blanks
(not nulls, blanks) but display actual data.
 
P

Peter

Mark Rae said:
[please don't top-post]
Yes I am calling BindEducationGrid() every time, currently there are only
3 records in the table and Rows.Count shows 3 rows but cells return
blanks (not nulls, blanks) but display actual data.

There's almost certainly your problem. Surround the BindEducationGrid() in
Page_Load with a check for postback:

if (!IsPostBack)
{
BindEducationGrid();
}

Sill getting the same problem, the grid knows how many rows and columns and
displays correct data but when I try to retreive values from a cell it's
allways blank
 
A

Allen Chen [MSFT]

Hi Peter,
but when I try to retrieve the data from a cell inside the RowDeleting event

protected void gvEducation_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
string transactionID = gvEducation.Rows[e.RowIndex].Cells[4].Text;

this._dt.DeleteEducation(transactionID);
this.BindEducationGrid();
}
the transactionID is always blank, but on the screen it displays values
(each cell has some value), actually all of the Cells return blanks, but
display data.


Could you post your aspx code? Are you using a control to render data, like
below?

<asp:TemplateField><ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("id")
%>'></asp:Label>
</ItemTemplate></asp:TemplateField>

If so the Text property of this Cell is always empty string.


Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter

Allen Chen said:
Hi Peter,
but when I try to retrieve the data from a cell inside the RowDeleting event

protected void gvEducation_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
string transactionID = gvEducation.Rows[e.RowIndex].Cells[4].Text;

this._dt.DeleteEducation(transactionID);
this.BindEducationGrid();
}
the transactionID is always blank, but on the screen it displays values
(each cell has some value), actually all of the Cells return blanks, but
display data.


Could you post your aspx code? Are you using a control to render data,
like
below?

<asp:TemplateField><ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("id")
%>'></asp:Label>
</ItemTemplate></asp:TemplateField>

If so the Text property of this Cell is always empty string.


Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support
Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

That was the problem, I had labels in those cells, sorry for wasting
everyones time!

I had couple of columns that did not have any controls, but the data in the
database was blank and I was looking at those cells and the ones with the
labels and forgot that I put labels on those cells.

Thank You for your help.
 
A

Allen Chen [MSFT]

That was the problem, I had labels in those cells, sorry for wasting
everyones time!

You're welcome Peter.

Thank you for using our Newsgroup Support Service!

Regards,
Allen Chen
Microsoft Online Community Support


=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
=================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top