J
jason
i'm trying to set the commandargument property of a buttoncolumn in the
DataGrid ItemBind event. it works fine in one instance, but in the
latest page i've written it doesn't seem to work, and i can't see why.
can anyone tell me why this chunk of code works:
[from File1.aspx]
<asp:datagrid id="DataGrid1" style="Z-INDEX: 104; LEFT: 16px;
POSITION: absolute; TOP: 136px" runat="server" CellPadding="3"
OnItemDataBound="DataGridBindEvent"
OnItemCommand="DataGridCommandEvent" AutoGenerateColumns="False">
<HeaderStyle Font-Bold="True" Wrap="False"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Ad ID">
<ItemTemplate>
<a href="<%# sRentClicksURL %>display.asp?adid=<%#
DataBinder.Eval(Container.DataItem, "Ad ID") %>"
target="new"><%# DataBinder.Eval(Container.DataItem, "Ad
ID") %>
</a>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Virtual Tour URL">
<ItemTemplate>
<a href="<%# DataBinder.Eval(Container.DataItem, "Virtual
Tour URL") %>" target="new"><%# DataBinder.Eval
(Container.DataItem, "Virtual Tour URL") %>
</a>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="URLText" Runat="Server" Size="55" Text='<%#
DataBinder.Eval(Container.DataItem, "Virtual Tour URL") %
</EditItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Approve" ButtonType="PushButton"
CommandName="Approve">
</asp:ButtonColumn>
<asp:ButtonColumn Text="Reject" ButtonType="PushButton"
CommandName="Reject">
</asp:ButtonColumn>
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Save
Edits" CancelText="Cancel Edits" EditText="Edit">
</asp:EditCommandColumn>
</Columns>
</asp:datagrid>
[from File1.aspx.vb]
Protected Sub DataGridBindEvent(ByVal sender As System.Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBound
Dim tItemType As ListItemType
tItemType = e.Item.ItemType
If tItemType = ListItemType.Header Or tItemType = _
ListItemType.Footer Or tItemType = ListItemType.Separator Then
Exit Sub
End If
Dim oRow As Common.DbDataRecord = CType(e.Item.DataItem, _
Common.DbDataRecord)
Dim sID As String = oRow(0)
Dim oButtonCell1 As TableCell = CType(e.Item.Controls(2), _
TableCell)
Dim oB1 As Button = CType(oButtonCell1.Controls(0), Button)
oB1.CommandArgument = sID
Dim oButtonCell3 As TableCell = CType(e.Item.Controls(3), _
TableCell)
Dim oB3 As Button = CType(oButtonCell3.Controls(0), Button)
oB3.CommandArgument = sID
End Sub
but this chunk doesn't:
[from File2.aspx]
<asp:datagrid id="DataGrid1" style="Z-INDEX: 104; LEFT: 24px;
POSITION: absolute; TOP: 320px" runat="server" Font-Size="Small"
CellPadding="3" Caption="<b>Results</b>" Visible="False"
OnItemDataBound="DataGridBindEvent"
OnItemCommand="DataGridCommandEvent">
<FooterStyle Wrap="False"></FooterStyle>
<SelectedItemStyle Wrap="False"></SelectedItemStyle>
<EditItemStyle Wrap="False"></EditItemStyle>
<AlternatingItemStyle Wrap="False"></AlternatingItemStyle>
<ItemStyle Wrap="False"></ItemStyle>
<HeaderStyle Font-Bold="True" Wrap="False"></HeaderStyle>
<Columns>
<asp:HyperLinkColumn Text="Edit" Target="_blank">
</asp:HyperLinkColumn>
<asp:ButtonColumn Text="Delete" ButtonType="LinkButton"
CommandName="Delete">
</asp:ButtonColumn>
</Columns>
</asp:datagrid>
? thanks for any help,
jason
DataGrid ItemBind event. it works fine in one instance, but in the
latest page i've written it doesn't seem to work, and i can't see why.
can anyone tell me why this chunk of code works:
[from File1.aspx]
<asp:datagrid id="DataGrid1" style="Z-INDEX: 104; LEFT: 16px;
POSITION: absolute; TOP: 136px" runat="server" CellPadding="3"
OnItemDataBound="DataGridBindEvent"
OnItemCommand="DataGridCommandEvent" AutoGenerateColumns="False">
<HeaderStyle Font-Bold="True" Wrap="False"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Ad ID">
<ItemTemplate>
<a href="<%# sRentClicksURL %>display.asp?adid=<%#
DataBinder.Eval(Container.DataItem, "Ad ID") %>"
target="new"><%# DataBinder.Eval(Container.DataItem, "Ad
ID") %>
</a>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Virtual Tour URL">
<ItemTemplate>
<a href="<%# DataBinder.Eval(Container.DataItem, "Virtual
Tour URL") %>" target="new"><%# DataBinder.Eval
(Container.DataItem, "Virtual Tour URL") %>
</a>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="URLText" Runat="Server" Size="55" Text='<%#
DataBinder.Eval(Container.DataItem, "Virtual Tour URL") %
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Approve" ButtonType="PushButton"
CommandName="Approve">
</asp:ButtonColumn>
<asp:ButtonColumn Text="Reject" ButtonType="PushButton"
CommandName="Reject">
</asp:ButtonColumn>
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Save
Edits" CancelText="Cancel Edits" EditText="Edit">
</asp:EditCommandColumn>
</Columns>
</asp:datagrid>
[from File1.aspx.vb]
Protected Sub DataGridBindEvent(ByVal sender As System.Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBound
Dim tItemType As ListItemType
tItemType = e.Item.ItemType
If tItemType = ListItemType.Header Or tItemType = _
ListItemType.Footer Or tItemType = ListItemType.Separator Then
Exit Sub
End If
Dim oRow As Common.DbDataRecord = CType(e.Item.DataItem, _
Common.DbDataRecord)
Dim sID As String = oRow(0)
Dim oButtonCell1 As TableCell = CType(e.Item.Controls(2), _
TableCell)
Dim oB1 As Button = CType(oButtonCell1.Controls(0), Button)
oB1.CommandArgument = sID
Dim oButtonCell3 As TableCell = CType(e.Item.Controls(3), _
TableCell)
Dim oB3 As Button = CType(oButtonCell3.Controls(0), Button)
oB3.CommandArgument = sID
End Sub
but this chunk doesn't:
[from File2.aspx]
<asp:datagrid id="DataGrid1" style="Z-INDEX: 104; LEFT: 24px;
POSITION: absolute; TOP: 320px" runat="server" Font-Size="Small"
CellPadding="3" Caption="<b>Results</b>" Visible="False"
OnItemDataBound="DataGridBindEvent"
OnItemCommand="DataGridCommandEvent">
<FooterStyle Wrap="False"></FooterStyle>
<SelectedItemStyle Wrap="False"></SelectedItemStyle>
<EditItemStyle Wrap="False"></EditItemStyle>
<AlternatingItemStyle Wrap="False"></AlternatingItemStyle>
<ItemStyle Wrap="False"></ItemStyle>
<HeaderStyle Font-Bold="True" Wrap="False"></HeaderStyle>
<Columns>
<asp:HyperLinkColumn Text="Edit" Target="_blank">
</asp:HyperLinkColumn>
<asp:ButtonColumn Text="Delete" ButtonType="LinkButton"
CommandName="Delete">
</asp:ButtonColumn>
</Columns>
</asp:datagrid>
? thanks for any help,
jason