call a server method from gridview's template field

G

Ganesh

Hi There,

I want to call a server method from gridview's template field, but it
doesn't seem to be working, any idea what is wrong in this.


Thanks
Ganesh


..aspx

<ItemTemplate>

<asp:Image BorderWidth=1 Height=16 Width=16 ID="Image1" runat="server"
ImageUrl='<%# Eval("City") %>' />

<asp:TextBox Text ='<%# Eval("City") %>' runat="server" />

<asp:TextBox ID="TextBox134" Text ='<%# CallTest(<%# Eval("City") %>) %>'
runat="server" />


</ItemTemplate>

</asp:TemplateField>



..aspx.cs



public string CallTest(string a)

{

return a;

}
 
G

Ganesh

i tried this one too but no luck

<asp:TextBox ID="TextBox134" Text ='<%# CallTest(Eval("SubCity")) %>'
runat="server" />
 
G

Ganesh

Is there anyway can i call a function from template field's item template
and assign the value back to text box

Thanks

Eliyahu Goldin said:
You are using databind expressions. How do you databind?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Ganesh said:
i tried this one too but no luck

<asp:TextBox ID="TextBox134" Text ='<%# CallTest(Eval("SubCity")) %>'
runat="server" />
 
E

Eliyahu Goldin

Your function will be called during databinding. How do you databind? Do you
set DataSourceID property? Or call DataBind() method? If you do one of them,
it should work. If you do none, it won't.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Ganesh said:
Is there anyway can i call a function from template field's item template
and assign the value back to text box

Thanks

Eliyahu Goldin said:
You are using databind expressions. How do you databind?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Ganesh said:
i tried this one too but no luck

<asp:TextBox ID="TextBox134" Text ='<%# CallTest(Eval("SubCity")) %>'
runat="server" />


Hi There,

I want to call a server method from gridview's template field, but it
doesn't seem to be working, any idea what is wrong in this.


Thanks
Ganesh


.aspx

<ItemTemplate>

<asp:Image BorderWidth=1 Height=16 Width=16 ID="Image1" runat="server"
ImageUrl='<%# Eval("City") %>' />

<asp:TextBox Text ='<%# Eval("City") %>' runat="server" />

<asp:TextBox ID="TextBox134" Text ='<%# CallTest(<%# Eval("City") %>)
%>' runat="server" />


</ItemTemplate>

</asp:TemplateField>



.aspx.cs



public string CallTest(string a)

{

return a;

}
 
M

Mark Rae [MVP]

<%#

That's a databinding expression - how are you doing the databinding...?
 

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

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top