Click here to Skip to main content
15,908,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
Sorry i dont know really how to explain this. I have Gridview that contain a dropdown list when i select a new data from the dropdown it should update in the text box near it.

<asp:GridView ID="Gvtimesheet" runat="server" AllowPaging="True"
AutoGenerateColumns="false"
OnPageIndexChanging="GvEmployeeTimeSchedule_PageIndexChanging"
OnRowCommand="GvEmployeeTimeSchedule_RowCommand1" Width="985px"
onrowdatabound="Gvtimesheet_RowDataBound"
onselectedindexchanged="Gvtimesheet_SelectedIndexChanged">
<HeaderStyle CssClass="GridviewScrollHeader" />
<rowstyle cssclass="GridviewScrollItem">
<alternatingrowstyle cssclass="GridviewScrollAlternateItem">
<pagersettings mode="NumericFirstLast" nextpagetext=">>">
PageButtonCount="5" Position="Bottom" PreviousPageText="<<" />
<pagerstyle cssclass="GridviewScrollPager">
<columns> <asp:BoundField DataField="employee_id" ReadOnly="true" HeaderText="Employee ID">
<HeaderStyle CssClass="gridheaderbg" HorizontalAlign="Center" />
<itemstyle cssclass="gridcol">
<footerstyle cssclass="gridheaderbg">

<asp:BoundField DataField="Name" ReadOnly="true" HeaderText="Name">
<HeaderStyle CssClass="gridheaderbg" HorizontalAlign="Center" />
<itemstyle cssclass="gridcol">
<footerstyle cssclass="gridheaderbg">

<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Day 1">
<itemtemplate>
<asp:Label ID="lblday1" runat="server" Text='<%# Bind("day1") %>' >
<asp:TextBox ID="txtday1" runat="server" Text='<%# Bind("day1") %>' Width="135px" >
<asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtenderday1" TargetControlID="txtday1" WatermarkText="HH:mm:ss - HH:mm:ss" runat="server">
<asp:DropDownList ID="ddllistallshiftday1" runat="server" OnSelectedIndexChanged="ddllistallshiftday_SelectedIndexChanged" AppendDataBoundItems="true" AutoPostBack="True" >






The dropdown in ddllistallshiftday1 contains
ddllistallshiftday1 .Items.Add(new ListItem(0,"--Select--"));
ddllistallshiftday1 .Items.Add(new ListItem(09:00:00-16:00:00,"Shift1"));
ddllistallshiftday1 .Items.Add(new ListItem(16:00:00-22:00:00,"Shift2"));

Which i get From database

when i select Shift2 From dropdown The corresponding value should be displayed in Textbox txtday1




Pls Help me.

Thanks in Advance
parithi
Posted
Comments
DipsMak 10-Mar-14 8:29am    
set dropdown autopostback property true..on postback find text box control using FindControl method and set the values of drop down
parithi vr 11-Mar-14 0:40am    
how to use Findcontrol method the following code return null

protected void ddllistallshiftday_SelectedIndexChanged(object sender, EventArgs e)
{

try
{
GridView GVph = (GridView)this.Master.FindControl("Gvtimesheet");
DropDownList ddllistallshiftday1 = (DropDownList)GVph.FindControl("ddllistallshiftday1") as DropDownList;
TextBox txtday1 = (TextBox)GVph.FindControl("txtday1") as TextBox;

}
catch
{
}
}

1 solution

Hi..
See this link!
http://www.aspdotnet-suresh.com/2012/10/jquery-get-selected-row-values-from.html[^]
and take values, update whatever u want from gridview (by checking only).
"Or"
http://www.aspdotnet-suresh.com/2011/02/how-to-inserteditupdate-and-delete-data.html[^]
Thank u.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900