Question on "OnRowEditing event"

S

stephen

Hi all,

If i have a gridview and have 3 columns of which i want to display only 2 as
one of them is "ID". why cant i access the ID value on the "RowUpdating"
event?
for eg:
<asp:GridView ID="gv_Sample" runat="server"
OnRowCancelingEdit="gv_Sample_RowCancelingEdit"
OnRowDataBound="gv_Sample_RowDataBound"
OnRowEditing="gv_Sample_RowEditing"
OnRowUpdating="gv_Sample_RowUpdating"
OnRowCommand="gv_Sample_RowCommand"
OnRowDeleting="gv_Sample_RowDeleting">
.....
<Columns>
<asp:BoundField DataField="ID" HeaderStyle-CssClass="hidden"
ItemStyle-CssClass="hidden" ReadOnly="true" />
<asp:TemplateField HeaderText="SiteName">
<ItemTemplate>
<asp:Label ID="lbl_SiteName" runat="server" Text='<%# Eval("SiteName")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SiteLocation">
<ItemTemplate>
<asp:Label ID="lbl_SiteLocation" runat="server" Text='<%#
Eval("SiteLocation") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="lnk_Update" runat="server" CausesValidation="True"
CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="lnk_Delete" runat="server" CausesValidation="False"
CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButton runat="server" ID="btn_Edit"
ImageUrl="~/Images/icon_miniinfo.gif"
CommandName="Edit" CausesValidation="False"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

On
protected void gv_Sample_RowUpdating(object sender, GridViewUpdateEventArgs
e)
{
.... I cant get the "ID" value from the BoundColumn...
}

Couple of question?
1. On Edit what does the "ID" Bound column convert itself? I understand that
in EditItemTemplate, the columns are converted to the respective controls
2. How can i get the values of the Hidden control?

Thanks and apprciate your help
Stephen
 
M

Manish

Hi Stephen,

I am able to replicate the issue with the GridView control. However, I tried
with our Grid control and it worked fine. If you want, you can try this
control from the link below:

http://download.componentone.com/pub/ASPNet/c1webgrid/

Protected Sub C1WebGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
C1.Web.C1WebGrid.C1ItemEventArgs) Handles C1WebGrid1.ItemDataBound
'Dim row As C1GridItem
'For Each row In Me.C1WebGrid1.Items
Response.Write(e.Item.Cells(0).Text + "<br/>")
' row.
'Next
End Sub

Regards,
Manish
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top