call a server method from gridview's template field

  • Thread starter Thread starter Ganesh
  • Start date Start date
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;

}
 
i tried this one too but no luck

<asp:TextBox ID="TextBox134" Text ='<%# CallTest(Eval("SubCity")) %>'
runat="server" />
 
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" />
 
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;

}
 
Back
Top