Get value from Gridview into textbox and dropDrownList controls

  Hi to all,

I (newbie) want that when user click on ID field of Gridview.The values of that particular ID row should display in the textbox and dropdown list of the page.

<asp:Label ID="lblAccessID" runat="server" Text="Access ID" Width="91px" Height="16px"></asp:Label>
        <asp:TextBox ID="txtAccessID" runat="server" Height="12px" Width="126px"></asp:TextBox> <br /><br />
        <asp:Label ID="lblAccessDesc" runat="server" Text="Access number" Width="91px" Height="16px"></asp:Label
        <asp:TextBox ID="txtAccessDesc" runat="server" Height="13px" Width="123px"></asp:TextBox><br /> <br />
        <asp:Label ID="lblTypeID" runat="server" Text="Type ID" Width="91px"></asp:Label>
        <asp:DropDownList ID="DDListType" runat="server" Width="98px">
        <asp:ListItem Selected="True" Value="1" Text="LAN"/>
        <asp:ListItem Value="0" Text="TFA"/>
        </asp:DropDownList><br /> <br />
        <asp:Label ID="lblStatus" runat="server" Text="Activation " Width="91px"></asp:Label>
        <asp:DropDownList ID="DDListStatus" runat="server" Width="98px">
        <asp:ListItem Selected="True" Value="1" Text="Active"/>
        <asp:ListItem Value="0" Text="Deactivate"/>
        </asp:DropDownList><br /> <br />
        <asp:Button ID="btnAdd" runat="server" Text="Add" Width="65px" OnClick="btnAdd_Click1" /> 
        <asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click1" /> 
        <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="btnDelete_Click1" /> 
        <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" /><br /><br />
        <asp:Label ID="lblMsg" runat="server"></asp:Label>
        <asp:GridView ID="myGridView" runat="server" AutoGenerateColumns="False"  AllowPaging  ="True"
AllowSorting ="True"   CellPadding  ="4"     ForeColor    ="#333333"   GridLines="None" >
        <asp:BoundField    HeaderText="ID"      DataField="ID"  />
        <asp:BoundField    HeaderText="Access Number"   DataField="Description" />
        <asp:BoundField    HeaderText="Type"  DataField="TypeID" />
        <asp:BoundField    HeaderText="Active"  DataField="Status" />
      <HeaderStyle         BackColor="#333399" ForeColor="White" Font-Bold="True" />
      <RowStyle            BackColor="#CCCCCC" />
      <AlternatingRowStyle BackColor="White" />
      <PagerStyle          BackColor="#333399" ForeColor="White" HorizontalAlign="Center" />



 Any suggestion or help ???

Thanks in advance




9/2/2006 6:57:16 AM 72751 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 45

in short use gridview and detailsview (or fromview) and you can do it without writing a single line of code. set datasource of grid (select * from tblName) , click on detailview and create new datasource (select * from tblName where ID = @ID) click that id parameter will take value from control, and from dropdown menu click on your gridview and click add, finish. Now when you select row in grid it will display details in detailsview - you can edit it to have textboxes , labels dropdowns menu - anything you want


You will find few articles about grd in here

hope it will help you understand how this works

Chicago Web Design
NMG Easy Site - professional site faster than ever ! hosting - the best way to find good, reliable hosting.
9/2/2006 2:44:03 PM

Thanks alot Tom.

9/3/2006 3:03:12 AM

Similar Artilces:

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,,MC...

How to add values to template control fields textbox control in GridView..
Hi all,    <asp:GridView ID="GridView1" EnableViewState="true" DataKeyNames="LicenseTemplateID"                       runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"                       Width="345px">                       <Columns>                           <asp:Templa...

Get controlID from control (textbox) inside another control (gridview)
Ok, so I've been trying to get a link within the edit item template of a gridview to open a new window.  I can do that fine, but when I try to pass the new window the controlID of the textbox to pass the value back to in the originating page I can't get the correct ID.  (that was a mouthful)  Maybe my code will explain better...  <EditItemTemplate> <asp:TextBox ID="EndTextBox" runat="server" Text='<%# Bind("endtime") %>'></asp:TextBox> <a href="javascript:;" onclick="

Problem getting an input value from a textbox in a GridView control
I placed a text box in one of my template columns in a gridview control:<Columns>                <asp:CommandField ShowEditButton="True" />                <asp:TemplateField><ItemTemplate><asp:TextBox runat=server ID="TextBox" Width="30"></asp:TextBox></ItemTemplate></asp:TemplateField> </Columns>Upon opening a page, my gridview is set up to be populate...

Problem getting input value from a textbox in a Gridview Control
I placed a text box in one of my template columns in a gridview control:<Columns>                <asp:CommandField ShowEditButton="True" />                <asp:TemplateField><ItemTemplate><asp:TextBox runat=server ID="TextBox" Width="30"></asp:TextBox></ItemTemplate></asp:TemplateField> </Columns>Upon opening a page, my gridview is set up to be populate...

Issue with getting values from child controls in a gridview, to use for the update using a SQLDataSource control
Hi all, I have a gridview bound with a SQLDataSource. I am using the Update feature of the SQLDataSource to update a SQL Server database with values entered into the gridview. However I am not getting it to work. I believe this is due to the controls that contain the user entries are not the gridview itself, but rather child controls within the gridview. I have been using the names of the actual controls but nothing happens. Upon submit, the screen returns blank, and the database is not updated. Here is some code:   <asp:GridView ID="GridEditSettlement" runat="server" AutoGenerate...

GridView child of GridView
I have a Parent GridView and when you click in the Edit one of the columns has a Template Field which has a Child GridView. When you click Edit on the Child GridView I have a Template Field that has a TextBox. How to I retreive this value of the TextBox? GridViewParent-- GridViewChild (Edit - Template Field containing this GridViewChild)----- TextBox inside Template Field in GridViewChild. Thank you.Peace in ChristMarco Napoli What you can do as a solution is to override the RowDataBound and try to find the child GridView control. Once you get a reference to...

Getting value from a textbox control that was filled with a value from javascript
 I have a textbox control (seen below txtMileageDollars1) that gets filled with javascript based on the number of miles a user types into another textbox (txtMileageMiles1) control.  When I post back with the submit button, the value is blank.  I've tried setting EnableViewState to false, but still cannot get a value on postback.  Does anyone have a solution?   Miles<asp:TextBox ID="txtMileageMiles1" runat="server" Width="50px"></asp:TextBox>   Total (txtMileageMiles1 * rate with javascript)<asp:TextBox...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

Control.Value and Control.SelectedItem.Value
Can someone explain to me the difference between say, Dropdownlist.SelectedItem.Value and Dropdownlist.SelectedValue?? Just curious, Thanks!Tim These are going to return the same thing. dropdownlist.selectedvalue is a shortcut to get the currently selected value in the dropdown. If that is all you want then you can just use that. If you want to access the currently selected item you can use dropdownlist.selecteditem and that return the item and you can then access any of the item's properties, including in this case the value property. If this post answered your question please r...

How to get the Value from the Textbox ?Textbox is created by using add control function.
  Dim textWG As New HtmlInputText textWG.text="Wage Rate" textWG.ID = "txtWG" me.control.add(textWG) i write this code at form load.moreover this form have one save button to save the value from the "txtWG" to database this textbox will be appear when form finish load.but after click save button the value cant be save into database. tat textbox become empty when user click the save button. how can i get the value from that textbox ? Please advice me.Thank you You are using a HTML control and by default, HTML controls dont have a mechanism to pres...

Help getting control name and value of dynamic controls
I have an application which creates a dynamic form consisting of an html table with web controls in the page. I need a user to be able to fill in this form and then grab the values of each control and save both the control name and the control value to a database. This is the Code that I have Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If not ispostback then Dim infotable As New Table Dim objparticipant As New Participants.ParticipantInfo Dim objCustomFields As New CustomFieldController Dim TypeId As Intege...

obtaining the value of a dropdown control inside a gridview control
Hi, I am working on a site to process assessments against a particular business service. The assessments have 8 stages and there are questions for each stage with a list of responses. I am experimenting with different user interfaces for doing this and am open for suggestions on the best way, but for the moment I have a page for each assessment with a dropdown list containing stage 1-8, on selecting a stage a gridview is built containing the questions and responses for that particular stage. So the first column is the question and the second column a drop down list of possible responses, o...

Web resources about - Get value from Gridview into textbox and dropDrownList controls -

Resources last updated: 12/12/2015 5:41:56 PM