Customized dynamic Datagrid component - help please

G

Guest

Hello,

I have a page that keeps repeating many times, with different datasets, for
the site, so it only makes sense to have a component that gets used. However,
the part of the grid I haven't been able to resolve.

here is the part that I haven't found a way for it to be dynamic,
"DataItem.IntClass"?

<asp:Label id="GrideID" text='<%# DataBinder.Eval(Container,
"DataItem.IntClass") %>' runat='server' />

Also like to know of any other approaches out there, or sites with related
info.

Thanks in advance,
Reza
 
E

Elton Wang

Hi Reza,

Actually, there is another way, codebehind, to deal with
any controls embedded in a datagrid. For example, to fill
Label, GrideID, in the datagrid, you can write code in
datagrid_ItemDataBound event:

ListItemType itemType = e.Item.ItemType;
if (itemType == ListItemType.Item || itemType ==
ListItemType.AlternatingItem){
DataRowView drv = (DataRowView)e.Item.DataItem;

Label lbl = (Label)e.FindControl("GrideID");
Lbl.Text = drv("IntClass").ToString;
// ...

}

HTH

Elton Wang
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top