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>
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>