D Patel
asked on
Textbox value does not return on gridview linkbutton click
Dear Experts,
Can anybody help me to sort out the issue?
Issue Description : I need to get the textbox entered value in gridview at the time of linkbutton click event.
Design Page :
Code Behind :
Here 'preference = Val(txtswap.Text)' I get the value as '0(Zero)'.
Actually I should get textbox entered value.
Can anyone help me please?
Regards,
D Patel
Can anybody help me to sort out the issue?
Issue Description : I need to get the textbox entered value in gridview at the time of linkbutton click event.
Design Page :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="prefLine"
AllowPaging="True" AllowSorting="True"
OnPageIndexChanging="GridView1_PageIndexChanging" Width="100%" BackColor="White" BorderColor="#999999" EnableModelValidation="True" GridLines="Vertical">
<Columns>
<asp:TemplateField HeaderText="Edit" >
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#String.Format("frmSls.aspx?id={0}&det={1}", HttpUtility.UrlEncode(Eval("nSlsID").ToString()), HttpUtility.UrlEncode(Eval("nSlsDetID").ToString())) %>'
Text="Edit" CommandName="select">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="nSlsDetID" HeaderText="Location">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="Position">
<ItemTemplate>
<asp:Label ID="lblRowNumber" Text='<%# Container.DataItemIndex + 1 %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Swap">
<ItemTemplate>
<telerik:RadNumericTextBox ID="txtSwapTo" Runat="server" Width="30px" NumberFormat-DecimalDigits="0" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:LinkButton ID="lnkSwap" CssClass="button" CommandArgument="swap" runat="server" Text="‡" OnClick="ChangePreference" Font-Bold="True" ForeColor="Maroon" Font-Size="Medium">
<img src="../images/swap-arrows.gif" height="16" width="16" alt=""/>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" BorderColor="Black" BorderStyle="Solid" VerticalAlign="Middle" />
<AlternatingRowStyle BackColor="#DCDCDC" />
<PagerSettings Position="TopAndBottom" />
</asp:GridView>
Code Behind :
Protected Sub ChangePreference(sender As Object, e As EventArgs)
Dim commandArgument As String = TryCast(sender, LinkButton).CommandArgument
Dim rowIndex As Double = TryCast(TryCast(sender, LinkButton).NamingContainer, GridViewRow).RowIndex
Dim rowtxt As GridViewRow = GridView1.Rows(rowIndex)
Dim locationId As Double = Convert.ToDouble(GridView1.Rows(rowIndex).Cells(1).Text)
Dim preference As Double = 0 'Convert.ToDouble(GridView1.DataKeys(rowIndex).Value)
Dim txtswap As RadNumericTextBox = TryCast(rowtxt.FindControl("txtSwapTo"), RadNumericTextBox)
preference = Val(txtswap.Text)
Me.UpdatePreference(locationId, preference)
fillDetaisTable(conn)
Response.Redirect(Request.Url.AbsoluteUri)
End Sub
Here 'preference = Val(txtswap.Text)' I get the value as '0(Zero)'.
Actually I should get textbox entered value.
Can anyone help me please?
Regards,
D Patel
ASKER
.value also not worked. It returning '0'
put a breakpoint here
Dim txtswap As RadNumericTextBox = TryCast(rowtxt.FindControl ("txtSwapT o"), RadNumericTextBox)
add watch this "txtswap" and "rowtxt.FindControl("txtSw apTo")"
then check all properties and values here
you should find what you need here...
also, check the value of Page.IsPostBack
Dim txtswap As RadNumericTextBox = TryCast(rowtxt.FindControl
add watch this "txtswap" and "rowtxt.FindControl("txtSw
then check all properties and values here
you should find what you need here...
also, check the value of Page.IsPostBack
also, what version are you using? people say there was a bug in version 2013.1.40
also, when you add a new textbox here, a regular one like
and use
do you get correct value from txtswapASP.Text?
<telerik:RadNumericTextBox ID="txtSwapTo" Runat="server" Width="30px" NumberFormat-DecimalDigits="0" />
<asp:textbox ID="txtSwapToASP" Runat="server" Width="30px" />
and use
Dim txtswap As RadNumericTextBox = TryCast(rowtxt.FindControl("txtSwapTo"), RadNumericTextBox)
Dim txtswapASP As TextBox = TryCast(rowtxt.FindControl("txtSwapToASP"), TextBox)
do you get correct value from txtswapASP.Text?
ASKER
you added a textbox next to RadNumericTextBox
you put some numbers to both
you clicked the linkbutton
and in the ChangePreference event, you get 0 from both control
is that right?
you put some numbers to both
you clicked the linkbutton
and in the ChangePreference event, you get 0 from both control
is that right?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, HainKurt,
You are correct that my code clears the value at databind.
I checked it.
I wrote code to databind was at after Not ISPostBack.
Thanks a lot.
You are correct that my code clears the value at databind.
I checked it.
I wrote code to databind was at after Not ISPostBack.
Thanks a lot.
ASKER
Thanks a lot.
Very good Troubleshooter
Very good Troubleshooter
check this
Getting and Setting Values
http://docs.telerik.com/devtools/aspnet-ajax/controls/input/getting-started/getting-and-setting-values