Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > template columns and bound columns in gridview

Reply
Thread Tools

template columns and bound columns in gridview

 
 
Vinki
Guest
Posts: n/a
 
      04-25-2007
Hello Everyone,

In my gridview, I changed some of the bound columns to template columns, I
noticed that the template column is not recognized inside the RowDataBound
event method. The reason I changed the bound columns to template columns so
that I can add the total column in the footer. I guess I cannot do that with
bound columns.
If I do e.Row.Cells[5].Text then 5th column is not recognixed inside the
Rowdatabound event, but If i do e.Row.Cells[4].Text then it is recognized.
Please let me know what am I doing wrong.

<asp:GridView ID="dgAgentActivity" runat="server"
AutoGenerateColumns="false" CellPadding="0" CellSpacing="1"
BackColor="AliceBlue" OnRowDataBound="dgAgentActivity_RowDataBound"
OnRowCreated="dgAgentActivity_RowCreated" ShowFooter="true">
<Columns>

<asp:BoundField HeaderText ="Time" DataField="SwitchTime" />
<asp:BoundField HeaderText ="State1" DataField="TerminalState" />
<asp:BoundField HeaderText ="State2" DataField="AgentState" />
<asp:BoundField HeaderText ="Que" DataField="Queue" />
<asp:BoundField HeaderText ="calculated Time"
DataField="calculated Time"/>


<asp:templatefield headertext="LogOut" >

<itemtemplate>
<%#Eval("LogOut", "{0:c}")%>
</itemtemplate>
<footertemplate>
<asp:label id="TotalTime" runat="server"/>
</footertemplate>
</asp:templatefield>
<asp:BoundField HeaderText ="test1 DataField="Not Ready" />


</Columns>


</asp:GridView>


protected void dgAgentActivity_RowDataBound(object sender,
GridViewRowEventArgs e)
{

}

Thanks.
 
Reply With Quote
 
 
 
 
Manish Bafna
Guest
Posts: n/a
 
      04-25-2007
Hi,
What i am going to tell is very basic but hoping that might help you.
You see it is zero based index.That is e.Row.Cells[4].Text will return
content of 5th column and .Row.Cells[0].Text will return content of 1st column
Hope this helps
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



"Vinki" wrote:

> Hello Everyone,
>
> In my gridview, I changed some of the bound columns to template columns, I
> noticed that the template column is not recognized inside the RowDataBound
> event method. The reason I changed the bound columns to template columns so
> that I can add the total column in the footer. I guess I cannot do that with
> bound columns.
> If I do e.Row.Cells[5].Text then 5th column is not recognixed inside the
> Rowdatabound event, but If i do e.Row.Cells[4].Text then it is recognized.
> Please let me know what am I doing wrong.
>
> <asp:GridView ID="dgAgentActivity" runat="server"
> AutoGenerateColumns="false" CellPadding="0" CellSpacing="1"
> BackColor="AliceBlue" OnRowDataBound="dgAgentActivity_RowDataBound"
> OnRowCreated="dgAgentActivity_RowCreated" ShowFooter="true">
> <Columns>
>
> <asp:BoundField HeaderText ="Time" DataField="SwitchTime" />
> <asp:BoundField HeaderText ="State1" DataField="TerminalState" />
> <asp:BoundField HeaderText ="State2" DataField="AgentState" />
> <asp:BoundField HeaderText ="Que" DataField="Queue" />
> <asp:BoundField HeaderText ="calculated Time"
> DataField="calculated Time"/>
>
>
> <asp:templatefield headertext="LogOut" >
>
> <itemtemplate>
> <%#Eval("LogOut", "{0:c}")%>
> </itemtemplate>
> <footertemplate>
> <asp:label id="TotalTime" runat="server"/>
> </footertemplate>
> </asp:templatefield>
> <asp:BoundField HeaderText ="test1 DataField="Not Ready" />
>
>
> </Columns>
>
>
> </asp:GridView>
>
>
> protected void dgAgentActivity_RowDataBound(object sender,
> GridViewRowEventArgs e)
> {
>
> }
>
> Thanks.

 
Reply With Quote
 
 
 
 
Vinki
Guest
Posts: n/a
 
      04-25-2007
Hi Manish,

Thanks for responding. I already know about zero based index. I think
template columns use differnt command to access the cells than bound columns.

"Manish Bafna" wrote:

> Hi,
> What i am going to tell is very basic but hoping that might help you.
> You see it is zero based index.That is e.Row.Cells[4].Text will return
> content of 5th column and .Row.Cells[0].Text will return content of 1st column
> Hope this helps
> --
> If my answer helped you,then please do press Yes below.
> Thanks and Regards.
> Manish Bafna.
> MCP and MCTS.
>
>
>
> "Vinki" wrote:
>
> > Hello Everyone,
> >
> > In my gridview, I changed some of the bound columns to template columns, I
> > noticed that the template column is not recognized inside the RowDataBound
> > event method. The reason I changed the bound columns to template columns so
> > that I can add the total column in the footer. I guess I cannot do that with
> > bound columns.
> > If I do e.Row.Cells[5].Text then 5th column is not recognixed inside the
> > Rowdatabound event, but If i do e.Row.Cells[4].Text then it is recognized.
> > Please let me know what am I doing wrong.
> >
> > <asp:GridView ID="dgAgentActivity" runat="server"
> > AutoGenerateColumns="false" CellPadding="0" CellSpacing="1"
> > BackColor="AliceBlue" OnRowDataBound="dgAgentActivity_RowDataBound"
> > OnRowCreated="dgAgentActivity_RowCreated" ShowFooter="true">
> > <Columns>
> >
> > <asp:BoundField HeaderText ="Time" DataField="SwitchTime" />
> > <asp:BoundField HeaderText ="State1" DataField="TerminalState" />
> > <asp:BoundField HeaderText ="State2" DataField="AgentState" />
> > <asp:BoundField HeaderText ="Que" DataField="Queue" />
> > <asp:BoundField HeaderText ="calculated Time"
> > DataField="calculated Time"/>
> >
> >
> > <asp:templatefield headertext="LogOut" >
> >
> > <itemtemplate>
> > <%#Eval("LogOut", "{0:c}")%>
> > </itemtemplate>
> > <footertemplate>
> > <asp:label id="TotalTime" runat="server"/>
> > </footertemplate>
> > </asp:templatefield>
> > <asp:BoundField HeaderText ="test1 DataField="Not Ready" />
> >
> >
> > </Columns>
> >
> >
> > </asp:GridView>
> >
> >
> > protected void dgAgentActivity_RowDataBound(object sender,
> > GridViewRowEventArgs e)
> > {
> >
> > }
> >
> > Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lower bound & Upper bound sunil panda Java 9 10-07-2008 08:32 PM
Get number of columns of a late bound GridView ctilly@gmail.com ASP .Net Web Controls 1 06-27-2006 12:53 PM
How to relate bound GridView columns to an unbound checkbox in the same row? keithb ASP .Net 1 04-08-2006 05:31 PM
Getting lower-bound and upper-bound of strings input Rhiner Dan C++ 1 03-27-2005 02:03 AM
Help a newbie... (DataGrid bound & template columns) =?Utf-8?B?RGF2aWQ=?= ASP .Net 2 02-10-2005 03:47 AM



Advertisments