hwo to convert into string in asp.net

Posted by Shanky11 under ASP.NET on 12/21/2012 | Points: 10 | Views : 2041 | Status : [Member] | Replies : 8
how to convert following in string--------its giving error

TextBox newname = (Convert.ToString(((TextBox)GridView1.FooterRow.FindControl("txtnewUserName")).Text));




Responses

Posted by: Ankitsrist on: 12/21/2012 [Member] Starter | Points: 25

Up
0
Down
use this......
TextBox newname=Convert.ToInt32(((TextBox)GridView1.FooterRow.FindControl("txtnewUserName")).Text);

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 12/21/2012 [Member] Starter | Points: 25

Up
0
Down
use this......
TextBox newname=Convert.ToInt32(((TextBox)GridView1.FooterRow.FindControl("txtnewUserName")).Text);

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/21/2012 [Member] Bronze | Points: 25

Up
0
Down
Use this..

TextBox newname=(TextBox)GridView1.FooterRow.FindControl("txtnewUserName");
Int i = Convert.ToInt32(newname.Text);

Mark the answer if this helps you

Thanks
Pavan Kumar
Mark Answer if this fits the need

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandhyab on: 12/21/2012 [Member] Starter | Points: 25

Up
0
Down
TextBox newname=(TextBox)GridView1.FooterRow.FindControl("txtnewUserName");
string name=newname.Text;//This is Enough If U want string; If you want to convert it into int
int i=Convert.ToInt16(newname.Text);

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 12/21/2012 [Member] Starter | Points: 25

Up
0
Down
thisis alll rt but name is showing blank value

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 12/21/2012 [Member] Starter | Points: 25

Up
0
Down
TextBox newname = (TextBox)GridView1.FooterRow.FindControl("txtnewUserName");
string s1 = Convert.ToString(newname.Text);
---------------not shoing any error but in s1 text comes blank--------------
i have a text box inside edit template swection in grdview

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandhyab on: 12/21/2012 [Member] Starter | Points: 25

Up
0
Down
If you dont enter anything in textbox then it will show null. If you enter something like sa in texbox then the value stored in name is sa. Check wheather you enterd in textbox


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 12/21/2012 [Member] Starter | Points: 25

Up
0
Down
see my designing part is --------------------------
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="491px" PageSize="3" EnableViewState="True" ShowFooter="true" ShowHeader="true"
HeaderStyle-BackColor="Aqua" Height="279px" DataKeyNames="name,age"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowcommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Name" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Name")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUserName" runat="Server" Text='<%# Eval("Name") %>'></asp:TextBox>
</EditItemTemplate>

<FooterTemplate>
<asp:TextBox ID="txtnewUserName" runat="Server"></asp:TextBox>
</FooterTemplate>

<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
</asp:TemplateField>

<asp:TemplateField HeaderText="Age">
<ItemTemplate>
<%#Eval("Age")%>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtUserage" runat="Server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<%#Eval("adress")%>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="Button1" runat="server" Text="Insert" CommandName="add" UseSubmitBehavior="false" />
</FooterTemplate>
</asp:TemplateField>

<asp:CommandField HeaderText="Delete" ShowDeleteButton="true"/>
<asp:CommandField HeaderText="Edit" ShowEditButton ="true" />
<asp:CommandField HeaderText="Select" ShowSelectButton="true" />
</Columns>
</asp:GridView>
---------------------------------now i hav written ths cod--------------------------------------
TextBox newname = (TextBox)GridView1.FooterRow.FindControl("txtnewUserName");
string s1 = Convert.ToString(newname.Text);


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response