Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting to a cell inside a datagrid, templateItem, td

Status
Not open for further replies.

timothy

Programmer
Mar 20, 2000
39
US
Hi anyone know how I can get to the cell: "<td><%# DataBinder.Eval(Container.DataItem, "USL")%></td>" in the below code to change it? For example:

This is how deep I have to go in the DataGrid (highlighted in blue)...


Code:
<Columns>
<asp:TemplateColumn>
  <ItemTemplate>
  <table>
  <tr>
  <td><%# DataBinder.Eval(Container.DataItem, "NAME")%></td>
  </tr>
  <tr>
  <td><%# DataBinder.Eval(Container.DataItem, "CITY")%>
  <%# DataBinder.Eval(Container.DataItem, "STATE")%>
  </td>
  </tr>

  <tr>
  [COLOR=blue]<td><%# DataBinder.Eval(Container.DataItem, "USL")%></td>[/color]
  </tr>

  </table>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>

I try this....

Code:
public void ItemDataBoundEventHandler(object sender, DataGridItemEventArgs e){
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem){
string aoru="";
aoru=Convert.ToString(DataBinder.Eval(e.Item.DataItem, "USL"));
if(aoru==""){
e.Item.Cells[0].Text="ASL";
}else{
e.Item.Cells[0].Text="USL";
}}}
But it looks like it is only picking up the "<asp:TemplateColumn>" no deeper.

Any idea how I can get to the cell:
<td><%# DataBinder.Eval(Container.DataItem, "USL")%></td>
and change the value in it?

I need to have multi values in the cell but need to be able to reach one of the values with code.

Thanks for your help!
 
change your approach use a label inside the datagrid.
<asp:Label id="CITY" runat="server"></asp:Label>

and then you can do a e.FindControl()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top