yep, I have already done with a invisible column and fetched the value, but I was wondering about the
<asp:ButtonColumn DataTextField
any way ..thanks for the efforts..Grant
Cheers ,
Vipul
hmm, not sure why you can't get it from the button column - you may need to cast it or something.
As a test, try create a BoundColumn before the Button column that contains the value your trying to Retrieve.
You can set the visibility to false if you don't want it to be seen,
then e.Item.Cells(0).Text should work
so:
<Columns>
<asp:BoundColumn DataField="CustomerCode" ></asp:BoundColumn> <!-- leave as visible to start off with so you can see the data is actually there -->
<asp:ButtonColumn DataTextField="CustomerCode" SortExpression="CustomerCode" HeaderText="Customer Code" CommandName="Select"></asp:ButtonColumn>
...
</Columns>
HTH
Customermaster.aspx
---------
<asp:datagrid id="dg" runat="server" Width="100%" Height="0px" BorderStyle="Solid" GridLines="Vertical" CellPadding="3" BackColor="White" BorderWidth="1px" BorderColor="White" AllowSorting="True" AutoGenerateColumns="False" PageSize="15">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#000099"></SelectedItemStyle>
<EditItemStyle CssClass="RowWhite"></EditItemStyle>
<AlternatingItemStyle Width="800px" CssClass="RowPaleBlue"></AlternatingItemStyle>
<ItemStyle CssClass="RowWhite"></ItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="Arial" Font-Bold="True" CssClass="HeaderRow"></HeaderStyle>
<FooterStyle BackColor="#CCCCCC"></FooterStyle>
<Columns>
<asp:ButtonColumn DataTextField="CustomerCode" SortExpression="CustomerCode" HeaderText="Customer Code" CommandName="Select"></asp:ButtonColumn>
<asp:BoundColumn DataField="CustomerName" HeaderText="Customer Name"></asp:BoundColumn>
<asp:BoundColumn DataField="StartDate" SortExpression="StartDate" HeaderText="Start Date" DataFormatString="{0:dd-MMM-yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="EndDate" SortExpression="EndDate" HeaderText="End Date" DataFormatString="{0:dd-MMM-yyyy}"></asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" Position="Top" CssClass="Pager" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
-------------------------------------
Customermaster.aspx.vb
Private Sub dg_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.ItemCommand
If e.CommandName = "Select" Then
Response.Redirect("CustomerDetail.aspx?CampaignId=" & e.Item.Cells(0).Text)
End If
End Sub
------------------
I get the values for other columns but not for select column using "e.Item.Cells(0).Text"