J
James Radke
Hello,
I am using a datagrid on a asp.net (1.1 version) webform.
In the .aspx page I have a blank ItemTemplate column defined as:
<asp:TemplateColumn HeaderText="Line-DL<br><br>">
<HeaderStyle HorizontalAlign="Center" Width="40px"
VerticalAlign="Bottom"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="40px"
VerticalAlign="Top"></ItemStyle>
<ItemTemplate></ItemTemplate>
</asp:TemplateColumn>
Then in the code behind, in the OnItemDataBound method I have:
Public Sub DoItemDataBound(ByVal objSource As Object, ByVal objArgs
As System.Web.UI.WebControls.DataGridItemEventArgs)
Dim itemType As System.Web.UI.WebControls.ListItemType =
objArgs.Item.ItemType
If itemType = System.Web.UI.WebControls.ListItemType.Item Or
itemType = System.Web.UI.WebControls.ListItemType.AlternatingItem Then
' Get the current data row in the grid
Dim myRow As DataRowView = CType(objArgs.Item.DataItem,
DataRowView)
If myRow("Status") = 3 Then
Dim x As New LinkButton
x.Text = myRow("LINNUM") & "-" & myRow("DELNUM")
x.CommandName = "Retrieve"
x.CausesValidation = False
x.ID = "lnkLineDL"
objArgs.Item.Cells(0).Controls.Add(x)
Else
objArgs.Item.Cells(0).Text = myRow("LINNUM") & "-" &
myRow("DELNUM")
End If
End If
End Sub
This works great to display the data, as only items with a status code 3
show the linkbutton.
Here is my problem: when I click on the linkbutton (currently no code
behind) the page refreshes and the values in the linkbutton are no longer
displayed for each row of data! Since the databind is not being hit there,
AND the rest of the datagrid retains it's data, I don't understand why the
linkbutton is disappearing from the screen.
Does anyone know what is going on?
Thanks!
Jim
I am using a datagrid on a asp.net (1.1 version) webform.
In the .aspx page I have a blank ItemTemplate column defined as:
<asp:TemplateColumn HeaderText="Line-DL<br><br>">
<HeaderStyle HorizontalAlign="Center" Width="40px"
VerticalAlign="Bottom"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="40px"
VerticalAlign="Top"></ItemStyle>
<ItemTemplate></ItemTemplate>
</asp:TemplateColumn>
Then in the code behind, in the OnItemDataBound method I have:
Public Sub DoItemDataBound(ByVal objSource As Object, ByVal objArgs
As System.Web.UI.WebControls.DataGridItemEventArgs)
Dim itemType As System.Web.UI.WebControls.ListItemType =
objArgs.Item.ItemType
If itemType = System.Web.UI.WebControls.ListItemType.Item Or
itemType = System.Web.UI.WebControls.ListItemType.AlternatingItem Then
' Get the current data row in the grid
Dim myRow As DataRowView = CType(objArgs.Item.DataItem,
DataRowView)
If myRow("Status") = 3 Then
Dim x As New LinkButton
x.Text = myRow("LINNUM") & "-" & myRow("DELNUM")
x.CommandName = "Retrieve"
x.CausesValidation = False
x.ID = "lnkLineDL"
objArgs.Item.Cells(0).Controls.Add(x)
Else
objArgs.Item.Cells(0).Text = myRow("LINNUM") & "-" &
myRow("DELNUM")
End If
End If
End Sub
This works great to display the data, as only items with a status code 3
show the linkbutton.
Here is my problem: when I click on the linkbutton (currently no code
behind) the page refreshes and the values in the linkbutton are no longer
displayed for each row of data! Since the databind is not being hit there,
AND the rest of the datagrid retains it's data, I don't understand why the
linkbutton is disappearing from the screen.
Does anyone know what is going on?
Thanks!
Jim