Boundcolumn or TemplateField when to use Boundcolumn and when TemplateField ????

M

mesut

Hi colleagues,

I'm confused when to use Boundcolumn and when to use TemplateField in
ASPX pages.
If I use BoundField control how can I get the field value in code
behind?

If I use BoundField I can't get the value in codebehind if I switch to
Template field I can get the value in code with following statment but
my sorting is disspeared?
_corpID = CType(row.FindControl("lblCorpID"), Label).Text

- can someone advice
- (1) when to use Boundcolumn and when to use Templatefield control?
- (2) how do I get the value in code behind if I use Boundcolumn
control?

regards,
mesut

Private Sub gvUsers_RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
gvUsers.RowCommand
Dim _corpID As String
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = gvUsers.Rows(index)
_corpID = CType(row.FindControl("lblCorpID"), Label).Text

(1)
<asp:BoundField DataField="CORPID" HeaderText="User"
SortExpression="CORPID" />

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

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

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top