Hi,<BR><BR>I have been grabbing the contents of a DataGrid cell by giving the index of the column, as follows:<BR><BR> hlViewItemText.NavigateURL="ViewItemText.aspx?ItemID=" & e.Item.Cells(1).Text<BR><BR>However, as I play around with the layout of the Columns in the DataGrid, I have to remember to change the number in the code snippet "e.Item.Cells(1).Text", so that I am still grabbing data out of the correct column.<BR><BR>This is a bit annoying, so I was hoping I could identify the column not by an index number, but by the HeaderText of the column, or by the data the column is bound to.<BR><BR>I experimented with syntax like e.Item.Cells("ItemID").Text, but got the usual error messages!<BR><BR>Is what I'm trying to do possible?<BR><BR>Thanks,<BR><BR>JON<BR><BR><BR><BR>************************************************** **************<BR> THE CODE<BR>************************************************** **************<BR><BR><%@ Page Language="VB" Debug="true" %><BR><%@ Import Namespace="System.Data" %><BR><%@ Import Namespace="System.Data.Oledb" %><BR><BR><script language="VB" runat="server"><BR> Dim objConn as New OleDbConnection ( ConfigurationSettings.AppSettings("ConnectionString"))<BR> Dim ds as Dataset = New DataSet()<BR> Dim objAdapter as New OleDbDataAdapter ( "SELECT * from tblItems", objConn )<BR> <BR> Sub Page_Load(sender as object, e as eventargs)<BR> objConn.Open()<BR> objAdapter.Fill(ds, "tblItems")<BR> dg.DataSource = ds<BR> dg.DataMember = "tblItems"<BR> <BR> If Not Page.IsPostBack Then<BR> dg.Databind()<BR> End If<BR> End Sub<BR> <BR> <BR> Sub myDataGrid_ItemDataBound(sender As Object, e As DataGridItemEventArgs)<BR> 'To add a dynamic hyperlink to the next page under the ItemText TextBox<BR> If (e.Item.ItemType = ListItemType.Item) or (e.Item.ItemType = ListItemType.AlternatingItem)<BR> dim hlViewItemText as new Hyperlink<BR> hlViewItemText.NavigateURL="ViewItemText.aspx?ItemID=" & e.Item.Cells(1).Text<BR> '************************************************* ******************<BR> 'Need to make this dynamic, in case I move the ItemID column!!!<BR> '************************************************* ******************<BR> hlViewItemText.Text="ViewItemText"<BR> e.Item.FindControl("HyperLinkPlaceHolder").Controls.Add(hlViewItemText) <BR> End if<BR> End sub<BR> <BR> <BR> <BR> sub dg_edit(sender as object, e as DataGridCommandEventArgs)<BR> dg.edititemindex = e.item.itemindex<BR> dg.databind()<BR> end sub<BR> <BR> sub dg_cancel(sender as object, e as DataGridCommandEventArgs)<BR> dg.edititemindex = -1<BR> dg.databind()<BR> end sub<BR> <BR> sub dg_update(sender as object, e as DataGridCommandEventArgs)<BR> 'Put something in here later<BR> end sub<BR> <BR></script> <BR><BR><html><body><BR> <form runat="server"><BR> <aspataGrid id="dg" runat="server"<BR> Bordercolor="black" <BR> gridlines="vertical"<BR> font-names="Arial" <BR> font-size="10pt"<BR> cellpadding="4"<BR> cellspacing="0"<BR> width="100%"<BR> ShowFooter="True"<BR> HeaderStyle-BackColor="#cccc99"<BR> FooterStyle-BackColor="#cccc99"<BR> ItemStyle-BackColor="#ffffff"<BR> AlternatingItemStyle-Backcolor="#cccccc"<BR> AutoGenerateColumns="False"<BR> OnItemDataBound="myDataGrid_ItemDataBound"<BR> OnEditCommand="dg_edit"<BR> OnCancelCommand="dg_cancel"<BR> OnUpdateCommand="dg_update"<BR> ><BR> <BR> <BR> <BR> <Columns><BR> <BR> <asp:editcommandcolumn HeaderText="EDIT" edittext="Edit" CancelText="Cancel" UpdateText="Save" HeaderText="" /><BR> <BR> <asp:boundcolumn readonly="true" HeaderText="ItemID" DataField="ItemID" /><BR> <asp:boundcolumn HeaderText="ItemTypeID" DataField="ItemTypeID" /><BR> <asp:boundcolumn readonly="true" HeaderText="ItemType" DataField="ItemType" /><BR> <asp:boundcolumn readonly="true" HeaderText="ItemTitle" DataField="ItemTitle" /><BR> <asp:boundcolumn readonly="true" HeaderText="ItemDescription" DataField="ItemDescription" /><BR> <BR> <BR> <%--<BR> <asp:TemplateColumn ItemStyle-VerticalAlign="Top" HeaderText="Various"><BR> <ItemTemplate><BR> <b>ItemType: </b><%# DataBinder.Eval(Container.DataItem, "ItemTypeID") %> - <%# DataBinder.Eval(Container.DataItem, "ItemType") %></b><BR><BR> <b>ItemTitle: </b><%# DataBinder.Eval(Container.DataItem, "ItemTitle" ) %><BR> <BR> <b>ItemDescription: </b><%# DataBinder.Eval(Container.DataItem, "ItemDescription" ) %><BR><BR> </ItemTemplate><BR> </asp:TemplateColumn><BR> --%><BR> <BR> <BR> <asp:TemplateColumn HeaderText="ItemText"><BR> <ItemTemplate><BR> <asp:TextBox runat="server" ReadOnly="True" Textmode="MultiLine" Columns="30" Rows="8" Text='<%# Container.DataItem("ItemText") %>' /><BR> <br/><BR> <asplaceholder runat="server" id="HyperLinkPlaceholder" /><BR> </ItemTemplate><BR> </asp:TemplateColumn><BR> <BR> <asp:boundcolumn HeaderText="PostedBy" DataField="PostedBy" /><BR> <asp:boundcolumn HeaderText="PostedDate" DataField="PostedDate" /><BR> <asp:boundcolumn HeaderText="ItemParent" DataField="ItemParent" /><BR> <asp:boundcolumn HeaderText="SortOrder" DataField="SortOrder" /><BR> <asp:boundcolumn HeaderText="ItemRating" DataField="ItemRating" /><BR> <asp:boundcolumn HeaderText="ModeratedYN" DataField="ModeratedYN" /><BR> <asp:boundcolumn HeaderText="JPStillToReplyYN" DataField="JPStillToReplyYN" /><BR> <asp:boundcolumn HeaderText="ArticleOriginalTitle" DataField="ArticleOriginalTitle" /><BR> <BR> </Columns><BR> <BR> <BR> </asp:dataGrid><BR> <BR> </form> <BR></body></html><BR><BR>