aspx_professional thread: Obtaining a Column Value from a DataView Linked to a DataList
syntax should be something like:
e.items.cells[index of cell you want].text
----Original Message Follows----
From: "Christopher Reed" <CReed@m...>
Reply-To: "ASPX_Professional" <aspx_professional@p...>
To: "ASPX_Professional" <aspx_professional@p...>
Subject: [aspx_professional] Obtaining a Column Value from a DataView Linked
to a DataList
Date: Thu, 14 Nov 2002 11:49:21 -0600
Hopefully I can describe what I am trying to do. I have a DataView with 5
columns that is DataBind-ed to a DataList. Within the DataList, I have a
LinkButton that calls the OnItemCommand associated function. What I want to
do is to obtain the value of the second column within the DataView for the
SelectedIndexItem of the DataGrid. I'm including some code, but I'm not
sure if it will help. It will definitely look ugly after it's been
reformatted by the mailing list.
Any help will be greatly appreciated!
Thanks..Chris
_____________________________________
Selected code from Program.aspx:
<asp:DataList id="dlProgram" BorderColor="Red" BorderWidth="1"
GridLines="Horizontal" OnItemCommand="dlProgram_ItemCommand" runat="server">
<AlternatingItemStyle BackColor="CornSilk" />
<SelectedItemStyle BackColor="LightBlue" />
<ItemTemplate>
<table width="400">
<tr>
<td width="200">
<%# DataBinder.Eval(Container.DataItem, "facility_name")%>
</td>
<td width="100">
<asp:LinkButton id="SelectProgram" CommandName="select" Text='<%#
DataBinder.Eval(Container.DataItem, "record_id")%>' runat="server" />
</td>
<td width="100">
<asp:LinkButton id="Jump2ProgDetails" CommandName="jump" Text="Program
Inspections" runat="server" />
</td>
</table>
</ItemTemplate>
<SelectedItemTemplate>
<table width="500">
<tr>
<td width="150">
<%# DataBinder.Eval(Container.DataItem, "facility_name")%>
</td>
<td width="250">
Program Identifier : <%# DataBinder.Eval(Container.DataItem,
"program_identifier")%>
<br />
Permit Dates :
<br />
From <%# DataBinder.Eval(Container.DataItem, "from_date", "{0:d}")%>
To <%# DataBinder.Eval(Container.DataItem, "from_date", "{0:d}")%>
<br />
Total Fee : <%# DataBinder.Eval(Container.DataItem, "total_fee_amt",
"{0:c}")%>
</td>
<td width="100">
<asp:LinkButton id="Jump2ProgDetails" CommandName="jump" Text="Program
Inspections" runat="server" />
</td>
</table>
</SelectedItemTemplate>
</asp:DataList>
Selected code from Program.cs:
public void dlProgram_ItemCommand(Object objSender, DataListCommandEventArgs
evtArgs)
{
string strCommand = ((LinkButton)evtArgs.CommandSource).CommandName;
if (strCommand == "select")
{
dlProgram.SelectedIndex = evtArgs.Item.ItemIndex;
}
else if (strCommand == "jump")
{
strProgramID = ???????["record_id"]; <--------------------- This is
where I want to capture the value for record_id from the DataView
Response.Redirect("inspect.aspx?Facility_ID=" + strFacilityID +
";Program_ID=" + strProgramID);
}
BindData();
}
Christopher Reed
Application Analyst
Web Development Coordinator
Information Technology
City of Lubbock
creed@m...
"The oxen are slow, but the earth is patient."
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail