Tag Archives: TextBox

[RESOLVED] Default button

I have a form that contains a text box and 02 buttons. 1. Search, 2. Clear.

The user types some text in the text box and then click the search button to search for the phrase users has entered in the text box. I wanted to make the searh button default, So that the user after entring text simply press the enter button to search for the text, instead of explicitly clicking the search button.


Hi, you use:

Form.DefaultSubmitButton = "mySearchButton";

HTH's 

You can also use "defaultbutton" property of form tag in aspx page to make any Button in your aspx page as default Button.


try this

Form.DefaultButton ="btnSubmit"


Hope this code helps you

<asp:Panel runat="server" ID="SearchPanel" DefaultButton="btn_search">


             <asp:TextBox ID="tb_search" runat="server"  ToolTip="Enter your search criteria" />
               
             <asp:Button ID="btn_search" runat="server" Text="search" Font-Names="Arial" OnClick="btn_search_Click" />

             <asp:Button ID="btn_Clear" runat="server" />
             
         </asp:Panel> 

Agree with Ramchandan.. You must use  Panel for achieve your functionality.


If you set Page's Default button property then for every unclicked thing it will fire DefaultButton Click which is wrong actually.



sayyed_kamran@hotmail.com

I wanted to make the searh button default, So that the user after entring text simply press the enter button to search for the text, instead of explicitly clicking the search button.

You can do that using Asp.net Focus API. please check out below link Focus API section :

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/tipstricks/default.aspx

[RESOLVED] autocomplete TextBox with data from a SQL SERVER

Hi all, im new at asp. net and im making a web page with 3 dropdownlist filtering DATA, and then i display a Gridview with the data selected. But i also have some TextBoxs and i want them to autocomplete according to the filters i previously selected. Im working all of this with no code behind.

Thank all, and here the code. I Bold The TextBox so you can see it clearly :D.

<%@ Import Namespace="System.Data" %>
<%@ Page Language="VB" Debug="True" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Data.OleDb.OleDbException" %>


<form id="form1" runat="server">


<asp:LinkButton ID="LinkButton5" runat="server" Text="Default"
    PostBackUrl="http://localhost:49724/Default.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton4" runat="server" Text="Editar/Actualizar/Eliminar Empleado"
    PostBackUrl="http://localhost:49724/EditEmpleado.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton7" runat="server" Text="Editar/Actualizar/Eliminar Producto"
    PostBackUrl="http://localhost:49724/EditProducto.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton8" runat="server" Text="Editar/Actualizar/Eliminar Categoria"
    PostBackUrl="http://localhost:49724/EditCategoria.aspx"></asp:LinkButton>


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"


    SelectCommand="SELECT [PROJID] FROM [sxb_Proyectos] ORDER BY [PROJID]">


</asp:SqlDataSource>


<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"


    SelectCommand="SELECT DISTINCT Ax50_Empleados.rut, Ax50_HorasRegistradas.rut
                    FROM Ax50_Empleados
                    INNER JOIN Ax50_HorasRegistradas
                    ON Ax50_Empleados.rut= Ax50_HorasRegistradas.rut
                    where ([PROJID] = CASE WHEN @PROJID = '-1' THEN [PROJID] ELSE @PROJID END)
                    ORDER BY Ax50_Empleados.rut">


<SelectParameters>


<asp:ControlParameter ControlID="DropDownList1" Name="PROJID" PropertyName="SelectedValue"/>


</SelectParameters>


</asp:SqlDataSource>


<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"


    SelectCommand="SELECT DISTINCT sxb_Producto.Producto, Ax50_HorasRegistradas.LINEPROPERTYID
                    FROM sxb_Producto
                    INNER JOIN Ax50_HorasRegistradas
                    ON sxb_Producto.Producto = Ax50_HorasRegistradas.LINEPROPERTYID
                    where (([rut] = CASE WHEN @rut=  '-1' THEN [rut] ELSE @rut END)
                    AND
                    ([PROJID] = CASE WHEN @PROJID = '-1' THEN [PROJID] ELSE @PROJID END))
                    ORDER BY sxb_Producto.Producto">


<SelectParameters>


<asp:ControlParameter ControlID="DropDownList2" Name="rut" PropertyName="SelectedValue"/>
<asp:ControlParameter ControlID="DropDownList1" Name="PROJID" PropertyName="SelectedValue"/>


</SelectParameters>


</asp:SqlDataSource>


<table>
<tr>
<td>Proyecto</td>
<td>


<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"  AppendDataBoundItems="true"
DataTextField="PROJID" DataValueField="PROJID">
<asp:ListItem Value="0"><Select an option></asp:ListItem>
<asp:ListItem Value="-1"><Select All></asp:ListItem>
                    

</asp:DropDownList>
</tr>


<tr>
<td>Rut Empleado</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2" AppendDataBoundItems="true" enableviewstate="false"
DataTextField="rut" DataValueField="rut">
<asp:ListItem Value="-1"><Select All></asp:ListItem>


</asp:Dropdownlist>


</td>
</tr>


<tr>
<td>Producto</td>
<td>
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" AppendDataBoundItems="true" enableviewstate="false"
DataValueField="Producto" DataTextField="Producto">
<asp:ListItem Value="-1"><Select All></asp:ListItem>


</asp:DropDownList>
</td>
</tr>
</table>
<br />
<hr />
<table><tr><td>Codigo Proyecto</td><td>Nombre Proyecto</td><td>Cliente</td></tr>
<tr><td>
    

</td>
<td>
    <asp:textbox runat="server" ReadOnly="True"></asp:textbox>
</td>
<td>
    <asp:textbox runat="server"></asp:textbox>
</td>


</tr>
</table>
<hr />


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="PROJID"
    DataSourceID="SqlDataSource4"
    EmptyDataText="There are no data records to display."
    onrowectedindexchanged="GridView1_SelectedIndexChanged">
    <Columns>
        <asp:TemplateField>
        <ItemTemplate>
        <asp:LinkButton ID="Editar" Text="Editar" runat="server" CommandName="Edit"></asp:LinkButton>
        </ItemTemplate>
        <EditItemTemplate>
        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" AutoPostBack="True" AppendDataBoundItems="true" enableviewstate="false"
            Text="Actualizar"></asp:LinkButton>
        <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" AutoPostBack="True"
            Text="Cancelar"></asp:LinkButton>
        </EditItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="PROJID" HeaderText="PROJID"
            SortExpression="PROJID" />
        <asp:BoundField DataField="rut" HeaderText="rut"
            SortExpression="rut" />
        <asp:BoundField DataField="LINEPROPERTYID" HeaderText="LINEPROPERTYID"
            SortExpression="LINEPROPERTYID" />
        <asp:BoundField DataField="QTY" HeaderText="QTY" SortExpression="QTY" />
        <asp:BoundField DataField="TXT" HeaderText="TXT" SortExpression="TXT" />
        <asp:BoundField DataField="TRANSDATE" HeaderText="TRANSDATE"
            SortExpression="TRANSDATE" DataFormatString="{0:d}" />
        <asp:BoundField DataField="Comentario" HeaderText="Comentario"
            SortExpression="Comentario" />
    </Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource4" runat="server"
    ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"
    ProviderName="<%$ ConnectionStrings:TestingConnectionString.ProviderName %>"
    SelectCommand="SELECT [PROJID], [rut], [LINEPROPERTYID], [QTY], [TXT], [TRANSDATE], [TRANSSTATUS], [DIMENSION], [DIMENSION3_], [Comentario]
                   FROM [Ax50_HorasRegistradas]
                   WHERE
                   (([rut] = CASE WHEN @rut=  '-1' THEN [rut] ELSE @rut END)
                   AND
                   ([PROJID] = CASE WHEN @PROJID = '-1' THEN [PROJID] ELSE @PROJID END)
                   AND
                   ([LINEPROPERTYID] = CASE WHEN @Producto = '-1' THEN [LINEPROPERTYID] ELSE @Producto END))"


     UpdateCommand="UPDATE [Ax50_HorasRegistradas] set Comentario = @Comentario WHERE PROJID = @PROJID AND TRANSDATE = @TRANSDATE">


<UpdateParameters>
<asp:Parameter Name="PROJID" />
<asp:Parameter Name="TRANSDATE" />
</UpdateParameters>


<SelectParameters>
<asp:ControlParameter ControlID="DropDownList2" Name="rut" PropertyName="SelectedValue"/>
<asp:ControlParameter ControlID="DropDownList1" Name="PROJID" PropertyName="SelectedValue"/>
<asp:ControlParameter ControlID="DropDownList3" Name="Producto" PropertyName="SelectedValue"/>
</SelectParameters>


</asp:SqlDataSource>
</form>


well it didnt bold the text box because i think is pasted codes, so the lines of the textbox are 107 and 110.

thank so much

Hi,


Check below links,


http://www.aspdotnetcodes.com/AutoComplete_From_Database.aspx

http://www.developerbarn.com/net-code-samples/75-using-ajax-auto-complete-extender-database.html



You can use ajax extensions and  web services:

.aspx page:

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </ajaxToolkit:ToolkitScriptManager>
  <div>
    <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"
            ServiceMethod="GetProducts" ServicePath="WebService.asmx" TargetControlID="txtSearch"> </ajaxToolkit:AutoCompleteExtender>
          </div>


WebService.cs:

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;

/// <summary>
/// Summary description for WebService
/// </summary>
[ScriptService]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService
{
    public WebService()
    {
        //Uncomment the following line if using designed components
        //InitializeComponent();
    }
    [WebMethod]
    public string[] GetProducts(string prefixText)
    {
       
            string sql = "Select rut from table Where rut like @prefixText";
            SqlDataAdapter da = new SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings["TestingConnectionString"].ToString());
            da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.NVarChar, 50).Value = prefixText + "%";
            DataTable dt = new DataTable();
            da.Fill(dt);
            string[] items = new string[dt.Rows.Count];
            int i = 0;
            foreach (DataRow dr in dt.Rows)
            {
                items.SetValue(dr["rut"].ToString(), i);
                i++;
            }
            return items;

        }


       
    }




 

 

hi, thanks for answering but with ajax it doesnt work, y pasted the code like this. 

<%@ Import Namespace="System.Data" %>
<%@ Page Language="VB" Debug="True" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Data.OleDb.OleDbException" %>


<script>


<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </ajaxToolkit:ToolkitScriptManager>
  <div>
    <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"
            ServiceMethod="GetProducts" ServicePath="WebService.asmx" TargetControlID="txtSearch"> </ajaxToolkit:AutoCompleteExtender>
          </div>


</script>






<form id="form1" runat="server">


<asp:LinkButton ID="LinkButton5" runat="server" Text="Default"
    PostBackUrl="http://localhost:49724/Default.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton4" runat="server" Text="Editar/Actualizar/Eliminar Empleado"
    PostBackUrl="http://localhost:49724/EditEmpleado.aspx"></asp:LinkButton>


............


and it give me an error "Etiqueta de servidor 'ajaxToolkit:ToolkitScriptManager' desconocida."

it doesnt recognize the ajaxtoolkit

Did you download and configure the ajax control toolkit with your Visual studio?

if not, you can download from here:

 http://www.asp.net/ajaxlibrary/act.ashx

http://ajaxcontroltoolkit.codeplex.com/releases/view/43475

 

 

 

 

ok i did all the steps of ajax and nothing happens,now i have this.


<%@ Import Namespace="System.Data" %>
<%@ Page Language="VB" Debug="True" %>


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Data.OleDb.OleDbException" %>
<%@ Import Namespace="AjaxControlToolkit" %>


 <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>
  <div>
    <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"
            ServiceMethod="GetProducts" ServicePath="WebService.asmx" TargetControlID="txtSearch"> </ajaxToolkit:AutoCompleteExtender>
  </div>




<form id="form1" runat="server">


<asp:LinkButton ID="LinkButton5" runat="server" Text="Default"
    PostBackUrl="http://localhost:49724/Default.aspx"></asp:LinkButton>
<br />
.
.
.
.
.
.


thanks very much for your help :D

Did you add the webservice.cs (with the GetProducts method) file in the app_code folder ?

if you did already, please mark out the line and start debugging and see if that is calling or not.....

i have the webservice in the same folder as the aspx web page, but what is that of getProducts method? it is something that i have to add as a line, its a file?


thank you for your time.

Please see my first reply.....you can see the GetProducts method there....

public string[] GetProducts(string prefixText)
    {......}


 

hi, and thanks for answering.

i have this for the moment in the aspx file.

<%@ Import Namespace="System.Data" %>
<%@ Page Language="VB" Debug="True" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Data.OleDb.OleDbException" %>
<%@ Import Namespace="AjaxControlToolkit" %>


<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>
  <div>
    <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"
            ServiceMethod="GetProducts" ServicePath="WebService.asmx" TargetControlID="txtSearch"> </ajaxToolkit:AutoCompleteExtender>
  </div>


<form id="form1" runat="server">


<asp:LinkButton ID="LinkButton5" runat="server" Text="Default"
    PostBackUrl="http://localhost:49724/Default.aspx"></asp:LinkButton>
<br />


and this in the .cs file

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;

/// <summary>  
/// Summary description for WebService  
/// </summary>  
[ScriptService]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService
{
    public WebService(prefixText)
    {
        //Uncomment the following line if using designed components  
        //InitializeComponent();  
    }
    [WebMethod]
    public string[] GetProducts(string prefixText)
    {

        string sql = "Select rut from table Where rut like @prefixText";
        SqlDataAdapter da = new SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings["TestingConnectionString"].ToString());
        da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.NVarChar, 50).Value = prefixText + "%";
        DataTable dt = new DataTable();
        da.Fill(dt);
        string[] items = new string[dt.Rows.Count];
        int i = 0;
        foreach (DataRow dr in dt.Rows)
        {
            items.SetValue(dr["rut"].ToString(), i);
            i++;
        }
        return items;

    }



}


and it gives me this error when i debug

Mensaje de error del analizador: Etiqueta de servidor 'ajaxToolkit:ToolkitScriptManager' desconocida.

Error de código fuente: 

Línea 7:  <%@ Import Namespace="AjaxControlToolkit" %>
Línea 8:  
Línea 9:  <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>   
Línea 10:   <div>    
Línea 11:     <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox> 

thanks for your answer


hi there, i still have this error and i did all of the ajax tools stuff

Línea 9:
Línea 10:
Línea 11: <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
Línea 12:   <div>
Línea 13:     <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>

this is my code. 


<%@ Import Namespace="AjaxControlToolkit" %>



<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
  <div>    
    <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>    
    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"     
            ServiceMethod="GetProducts" ServicePath="WebService.cs" TargetControlID="txtSearch"> </ajaxToolkit:AutoCompleteExtender>    
  </div> 
</ajaxToolkit:ToolkitScriptManager> 
<form id="form1" runat="server">



i change the code to this and i can see the page now, but the text doesnt show anything.

<%@ Import Namespace="AjaxControlToolkit" %>


<form id="form1" runat="server">


<ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
  <div>
    <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
    <AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"
            ServiceMethod="GetProducts" ServicePath="WebService.cs" TargetControlID="txtSearch"> </AutoCompleteExtender>
  </div>
</ToolkitScriptManager>



Hello,

please read my first post carefully and see there the servicepath="Webservice.asmx"....put the code inside the webservice.cs file! 

great thanks so much!

show data in a textbox automatically when i choose an item in a dropdownlist

hi all, i have a web page, with some filters using dropdownlist, and when i select items from these dropdownlist, a gridview appear showing data from a sql server. The idea is that when i select an item, from the first or second drop down list, in a textbox appear for example the name of the item i choose from the dropdownlist.

Thanks all for your help. Here is the code. I use only VB and not C#.

<%@ Import Namespace="System.Data" %>
<%@ Page Language="VB" Debug="True" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Data.OleDb.OleDbException" %>
<%@ import Namespace="System.Web.UI.WebControls.DataControlFieldCollection" %>
<%@ import Namespace="System.Web.UI.HtmlControls.HtmlGenericControl" %>


<script runat="server">
    

    Dim Proyectos As SqlDataSource
    

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    

        Proyectos = New SqlDataSource
        

        Dim sConnString As String
        sConnString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("TestingConnectionString").ConnectionString
        Proyectos.ConnectionString = sConnString
        Proyectos.ID = "Proyectos"
        

        ' Now configure the INSERT statement. We have to declare the Parameters here
        Proyectos.InsertCommand = "INSERT INTO [sxb_Conocimiento] ([Rut],[IdProducto],[IdCategoria],[Experiencia]) VALUES (@Rut, @IdProducto, @IdCategoria, @Experiencia)"
        Proyectos.InsertParameters.Add("Rut", "")
        Proyectos.InsertParameters.Add("IdProducto", "")
        Proyectos.InsertParameters.Add("IdCategoria", "")
        Proyectos.InsertParameters.Add("Experiencia", "")
        

        Me.Controls.Add(Proyectos)
  

    End Sub
    

    ' The following code is triggered when the Insert button is pressed.
    Protected Sub bInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        ' Clear insert Parameters
        Proyectos.InsertParameters.Clear()
        ' Add parameters with values form Text boxes
        Proyectos.InsertParameters.Add("Rut", Rut.Text.ToString)
        Proyectos.InsertParameters.Add("IdProducto", IdProducto.Text.ToString)
        Proyectos.InsertParameters.Add("IdCategoria", IdCategoria.Text.ToString)
        Proyectos.InsertParameters.Add("Experiencia", Experiencia.Text.ToString)
        ' Do the INSERT command
        Proyectos.Insert()
    End Sub


</script>


<form id="form1" runat="server">


<asp:LinkButton ID="LinkButton5" runat="server" Text="Default"
    PostBackUrl="http://localhost:49724/Default.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton4" runat="server" Text="Editar/Actualizar/Eliminar Empleado"
    PostBackUrl="http://localhost:49724/EditEmpleado.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton7" runat="server" Text="Editar/Actualizar/Eliminar Producto"
    PostBackUrl="http://localhost:49724/EditProducto.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton8" runat="server" Text="Editar/Actualizar/Eliminar Categoria"
    PostBackUrl="http://localhost:49724/EditCategoria.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton9" runat="server" Text="Editar/Actualizar/Eliminar Valores"
    PostBackUrl="http://localhost:49724/EditValores.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton10" runat="server" Text="Editar/Actualizar/Eliminar Conocimiento"
    PostBackUrl="http://localhost:49724/EditConocimiento.aspx"></asp:LinkButton>


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"
    SelectCommand="SELECT DISTINCT [Rut] FROM [sxb_Conocimiento]
                    ORDER BY [Rut]">
</asp:SqlDataSource>


<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"
    SelectCommand="SELECT DISTINCT [IdProducto] FROM [sxb_Conocimiento]
                    WHERE ([Rut] = CASE WHEN @Rut = '-1' THEN [Rut] ELSE @Rut END)
                    ORDER BY [IdProducto]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Rut" PropertyName="SelectedValue"/>
</SelectParameters>
</asp:SqlDataSource>


<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"
    SelectCommand="SELECT DISTINCT [IdCategoria] FROM [sxb_Conocimiento]
                    WHERE
                    (([Rut] = CASE WHEN @Rut = '-1' THEN [Rut] ELSE @Rut END)
                    AND
                    ([IdProducto] = CASE WHEN @IdProducto = '-1' THEN [IdProducto] ELSE @IdProducto END))
                    ORDER BY [IdCategoria]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Rut" PropertyName="SelectedValue"/>
<asp:ControlParameter ControlID="DropDownList2" Name="IdProducto" PropertyName="SelectedValue"/>
</SelectParameters>
</asp:SqlDataSource>


<asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"
    SelectCommand="SELECT DISTINCT [Experiencia] FROM [sxb_Conocimiento]
                    WHERE
                    (([Rut] = CASE WHEN @Rut = '-1' THEN [Rut] ELSE @Rut END)
                    AND
                    ([IdProducto] = CASE WHEN @IdProducto = '-1' THEN [IdProducto] ELSE @IdProducto END)
                    AND
                    ([IdCategoria] = CASE WHEN @IdCategoria = '-1' THEN [IdCategoria] ELSE @IdCategoria END))
                    ORDER BY [Experiencia]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Rut" PropertyName="SelectedValue"/>
<asp:ControlParameter ControlID="DropDownList1" Name="IdProducto" PropertyName="SelectedValue"/>
<asp:ControlParameter ControlID="DropDownList1" Name="IdCategoria" PropertyName="SelectedValue"/>
</SelectParameters>
</asp:SqlDataSource>


<table>
<tr>
<td>Rut</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
        DataSourceID="SqlDataSource1"  AppendDataBoundItems="true" enableviewstate="false"
DataTextField="Rut" DataValueField="Rut" DataTextFormatString="{0}">
<asp:ListItem Value="0"><Select an option></asp:ListItem>
<asp:ListItem Value="-1"><Select All></asp:ListItem>
</asp:DropDownList>
</tr>


<tr>
<td>Producto</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2" AppendDataBoundItems="true" enableviewstate="false"
DataTextField="IdProducto" DataValueField="IdProducto">
<asp:ListItem Value="-1"><Select All></asp:ListItem>
</asp:Dropdownlist>
</td>
</tr>


<tr>
<td>Categoria</td>
<td>
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" AppendDataBoundItems="true" enableviewstate="false"
DataTextField="IdCategoria" DataValueField="IdCategoria">
<asp:ListItem Value="-1"><Select All></asp:ListItem>
</asp:Dropdownlist>
</td>
</tr>


<tr>
<td>Experiencia</td>
<td>
<asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource4" AppendDataBoundItems="true" enableviewstate="false"
DataTextField="Experiencia" DataValueField="Experiencia">
<asp:ListItem Value="-1"><Select All></asp:ListItem>
</asp:Dropdownlist>
</td>
</tr>
</table>


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AutoPostBack="True" DataKeyNames="Rut" enableviewstate="false" AppendDataBoundItems="true"
    DataSourceID="SqlDataSource5"
    EmptyDataText="There are no data records to display.">
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
    <asp:LinkButton ID="Editar" Text="Editar" runat="server" CommandName="Edit"></asp:LinkButton>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" AutoPostBack="True" AppendDataBoundItems="true" enableviewstate="false"
        Text="Actualizar"></asp:LinkButton>
    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" AutoPostBack="True"
        Text="Cancelar"></asp:LinkButton>
    </EditItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField>
    <ItemTemplate>
    <asp:LinkButton ID="Apagar" Text="Eliminar" runat="server" CommandName="Delete" OnClientClick='return confirm("Esta seguro que quiere borrar este registro?");' AutoPostBack="True" enableviewstate="false" CausesValidation="false"></asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="Rut" HeaderText="Rut" SortExpression="Rut" />
    <asp:BoundField DataField="IdProducto" HeaderText="IdProducto" SortExpression="IdProducto" />
    <asp:BoundField DataField="IdCategoria" HeaderText="IdCategoria"
        SortExpression="IdCategoria" />
    <asp:BoundField DataField="Experiencia" HeaderText="Experiencia"
        SortExpression="Experiencia" />
    <asp:BoundField DataField="Resultado" HeaderText="Resultado"
        SortExpression="Resultado" />
    </Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource5" runat="server"
    ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"
    ProviderName="<%$ ConnectionStrings:TestingConnectionString.ProviderName %>"
    SelectCommand="SELECT DISTINCT [Rut], [IdProducto], [IdCategoria], [Experiencia], [Resultado] FROM [sxb_Conocimiento]
                   WHERE
                   (([Rut] = CASE WHEN @Rut= '-1' THEN [Rut] ELSE @Rut END)
                   AND
                   ([IdProducto] = CASE WHEN @IdProducto = '-1' THEN [IdProducto] ELSE @IdProducto END)
                   AND
                   ([IdCategoria] = CASE WHEN @IdCategoria = '-1' THEN [IdCategoria] ELSE @IdCategoria END)
                   AND
                   ([Experiencia] = CASE WHEN @Experiencia = '-1' THEN [Experiencia] ELSE @Experiencia END))"


    UpdateCommand="UPDATE [sxb_Conocimiento] set IdProducto = @IdProducto, IdCategoria = @IdCategoria, Experiencia = @Experiencia where Rut = @Rut"


    InsertCommand="INSERT INTO [sxb_Conocimiento] (Rut, IdProducto, IdCategoria, Experiencia) VALUES (@Rut, @IdProducto, @IdCategoria, @Experiencia)"


    DeleteCommand="DELETE from [sxb_Conocimiento] where Rut = @Rut">


    <UpdateParameters>
    <asp:Parameter Name="Rut" />
    </UpdateParameters>


    <DeleteParameters>
    <asp:Parameter Name="Rut"/>
    </DeleteParameters>


    <SelectParameters>
    <asp:ControlParameter ControlID="DropDownList1" Name="Rut" PropertyName="SelectedValue"/>
    <asp:ControlParameter ControlID="DropDownList2" Name="IdProducto" PropertyName="SelectedValue"/>
    <asp:ControlParameter ControlID="DropDownList3" Name="IdCategoria" PropertyName="SelectedValue"/>
    <asp:ControlParameter ControlID="DropDownList4" Name="Experiencia" PropertyName="SelectedValue"/>
    </SelectParameters>


</asp:SqlDataSource>
<br />
<br />
<table>
<tr>
<td>Ingrese Rut</td>
<td>
<asp:TextBox ID="Rut" runat="server"></asp:TextBox>
</tr>
<td>Ingrese IdProducto</td>
<td>
<asp:TextBox ID="IdProducto" runat="server"></asp:TextBox>
</tr>
<td>Ingrese IdCategoria</td>
<td>
<asp:TextBox ID="IdCategoria" runat="server"></asp:TextBox>
</tr>
<td>Ingrese Experiencia</td>
<td>
<asp:TextBox ID="Experiencia" runat="server"></asp:TextBox>
</tr>
</table>


<asp:LinkButton ID="bInsert" runat="server" CausesValidation="True" CommandName="Insert" AutoPostBack="True" AppendDataBoundItems="true" enableviewstate="false" onclick="bInsert_Click"
    Text="Ingresar"></asp:LinkButton>


</form>



if you want to set a textbox's text property according to the selection change of dropdownlist then you can use 

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
         DataSourceID="SqlDataSource1"  AppendDataBoundItems="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" enableviewstate="false"
 DataTextField="Rut" DataValueField="Rut" DataTextFormatString="{0}">
 <asp:ListItem Value="0"><Select an option></asp:ListItem>
 <asp:ListItem Value="-1"><Select All></asp:ListItem>
 </asp:DropDownList>


 Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


                TextBox1.Text = DropDownList1.SelectedItem.Name
or
                TextBox1.Text = DropDownList1.SelectedValue
            

    End Sub




hi, thanks so much for answering, i changed my code to this :D


<%@ Import Namespace="System.Data" %>
<%@ Page Language="VB" Debug="True" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Data.OleDb.OleDbException" %>
<%@ Import Namespace="AjaxControlToolkit" %>
<script runat="server">
 

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
  

        TextBox.Text = DropDownList1.SelectedItem.Name
              

    End Sub
</script>


<form id="form1" runat="server">


<asp:LinkButton ID="LinkButton5" runat="server" Text="Default"
    PostBackUrl="http://localhost:49724/Default.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton4" runat="server" Text="Editar/Actualizar/Eliminar Empleado"
    PostBackUrl="http://localhost:49724/EditEmpleado.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton7" runat="server" Text="Editar/Actualizar/Eliminar Producto"
    PostBackUrl="http://localhost:49724/EditProducto.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton8" runat="server" Text="Editar/Actualizar/Eliminar Categoria"
    PostBackUrl="http://localhost:49724/EditCategoria.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton9" runat="server" Text="Editar/Actualizar/Eliminar Valores"
    PostBackUrl="http://localhost:49724/EditValores.aspx"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton10" runat="server" Text="Editar/Actualizar/Eliminar Conocimiento"
    PostBackUrl="http://localhost:49724/EditConocimiento.aspx"></asp:LinkButton>


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"
    SelectCommand="SELECT [PROJID] FROM [sxb_Proyectos] ORDER BY [PROJID]">
</asp:SqlDataSource>


<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"
    SelectCommand="SELECT DISTINCT Ax50_Empleados.rut, Ax50_HorasRegistradas.rut
                    FROM Ax50_Empleados
                    INNER JOIN Ax50_HorasRegistradas
                    ON Ax50_Empleados.rut= Ax50_HorasRegistradas.rut
                    where ([PROJID] = CASE WHEN @PROJID = '-1' THEN [PROJID] ELSE @PROJID END)
                    ORDER BY Ax50_Empleados.rut">


<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="PROJID" PropertyName="SelectedValue"/>
</SelectParameters>
</asp:SqlDataSource>


<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:TestingConnectionString %>"
    SelectCommand="SELECT DISTINCT sxb_Producto.Producto, Ax50_HorasRegistradas.LINEPROPERTYID
                    FROM sxb_Producto
                    INNER JOIN Ax50_HorasRegistradas
                    ON sxb_Producto.Producto = Ax50_HorasRegistradas.LINEPROPERTYID
                    where (([rut] = CASE WHEN @rut=  '-1' THEN [rut] ELSE @rut END)
                    AND
                    ([PROJID] = CASE WHEN @PROJID = '-1' THEN [PROJID] ELSE @PROJID END))
                    ORDER BY sxb_Producto.Producto">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList2" Name="rut" PropertyName="SelectedValue"/>
<asp:ControlParameter ControlID="DropDownList1" Name="PROJID" PropertyName="SelectedValue"/>
</SelectParameters>
</asp:SqlDataSource>


<table>
<tr>
<td>Proyecto</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"  AppendDataBoundItems="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
DataTextField="PROJID" DataValueField="PROJID">
<asp:ListItem Value="0"><Select an option></asp:ListItem>
<asp:ListItem Value="-1"><Select All></asp:ListItem>
</asp:DropDownList>
</tr>


<tr>

this is the text box and the error

 

<td>
    <asp:textbox ID="textbox" runat="server" ReadOnly="True"></asp:textbox>
</td>

Mensaje de error del compilador: BC30456: 'Name' no es un miembro de 'System.Web.UI.WebControls.ListItem'.

Error de código fuente:

Línea 10: Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)  
Línea 11:   
Línea 12:         TextBox.Text = DropDownList1.SelectedItem.Name
Línea 13:               
Línea 14:     End Sub

Please use

DropDownList1.SelectedItem.Text

instead of

DropDownList1.SelectedItem.Name

Sorry for the misinformation

REAL NICE, thanks for your help, but now, how can i show in that Textbox, not the item that i selected, but an item that is in the same table where i get the data to fill the dropdownlist. All the data is in a LOCAL SQL SERVER. In me table i have serveral columns and with the first dropdownlist as you can see i select one. But in the textbox i want to show other column.

the table has

PROJID RUT LINEPROPERTYID QTY TXT TRANSDATE TRANSTATUS columns. The first dropdown select the PROJID columns and in the textbox i would like to show for example the LINEPROPERTYID data according for what i selected in the dropdownlist. 

thank you so much :D

[RESOLVED] Textboxes and Calendar Controls

How would I create a row by column structure dynamically that has column 1 as text boxes and column 2 as calendar controls? The number of rows is some positive integer. Is it best to store these controls in a grid?

What would the code look like?

Thanks, Dave

drl

has column 1 as text boxes and column 2 as calendar controls? 

You can use a GridView with two template fields.

<asp:GridView runat="server" ID="GridView1" AutoGenerateColumns="false">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:TextBox runat="server" ID="TextBox1"></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

And you need to add your code for databinding the gridview or setting text/selected date for calendar.

Santhosh, thank you for your reply. Now how would I access say the textboxes in each row of the grid? Do they all have the same name "TextBox1"? Then which is which?

Please show a line or two of code to access the textboxes in the grid. Thanks. 

If you want to show just few rows of empty textboxes and calendar, you need to bind Gridview to an integer array.

//Just to bind 5 empty rows of data
GridView1.DataSource = new[] { 1, 2, 3, 4, 5 };
GridView1.DataBind();

If you want to access values from GridView, you can do this

//Retrieving values
foreach (GridViewRow row in GridView1.Rows)
{
    TextBox TextBox1 = (TextBox)row.FindControl("TextBox1");
    Calendar Calendar1 = (Calendar)row.FindControl("Calendar1");

    //values
    string text = TextBox1.Text;
    string date = Calendar1.SelectedDate.ToShortDateString();
    //do something with values here
}

Change ControlIDs in the FindControl according to your gridview markup. Try that way and see if it works.

GridView1.DataSource = new[] { 1, 2, 3, 4, 5 };

The compiler did not like this line - type expected at the "["... any suggestions? Thanks. 

drl

type expected at the "["

Ok, just specify int.

//Just to bind 5 empty rows of data
GridView1.DataSource = new int[] { 1, 2, 3, 4, 5 };
GridView1.DataBind();

GridView1.DataSource = new int[] { 1, 2, 3, 4, 5 };

GridView1.DataBind();

I ran just that much and the textboxes are clear. They have no value.

What's up?

drl

I ran just that much and the textboxes are clear. They have no value.

Can you pls explain clearly what you are tyring to do. TextBox will not contain any text as such unless until you specify which property to bind to using Text Ex: Text='<%# Eval("Some Property")%>'

I thought you are just trying to present a tabular Data Entry screen wherein user enters value and picks a date. If that's not the requirement, explain what you are trying to do.

"I thought you are just trying to present a tabular Data Entry screen wherein user enters value and picks a date." 

Yes, this is what I want with the addition of when the page first displays, the textboxes are filled with the integers initialized in the Gridview1.Datasource = new int[] = {1,2,3,4,5} statement.

drl

when the page first displays, the textboxes are filled with the integers

Check this

<asp:GridView runat="server" ID="GridView1" AutoGenerateColumns="false">
    <Columns>
        <asp:TemplateField HeaderText="Number" ItemStyle-VerticalAlign="Top">
            <ItemTemplate>
                <asp:TextBox runat="server" Text='<%# Container.DataItem %>' ID="TextBox1"></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Date">
            <ItemTemplate>
                <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        //Just to bind 5 empty rows of data
        GridView1.DataSource = new int[] { 1, 2, 3, 4, 5 };
        GridView1.DataBind();
    }
}

Works perfectly, thanks!

[RESOLVED] Avoid loding data when user unselect

I have checkbox control in Gridview when i selected checkbox entire row will be loaded into corresponding Textboxes, up to here every thing fine when i unchecked again entire row is populating/loading into corresponding Textboxes i dont want to be happen this when i unchecked data should not be loaded.

Anothere one is if i checked "A" record earlier, simulataniously when i checked "B" record "A" record should be un checked automatically but for me it is not happening both records are checked.

how can i acheive above to please help,Thanks

Gridview with checkbox

<asp:GridView ID="GVStatus" runat="server" CellPadding="3" ForeColor="#333333"
            GridLines="Vertical" Height="16px" Width="180px"  AutoGenerateColumns="false"
            EnableModelValidation="True" style="margin-top: 0px" Font-Size="Medium"
                   ToolTip="List of Jobs  from the Database">
             <RowStyle BackColor="#EFF3FB" />
             <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
             <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
             <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
             <HeaderStyle  BackColor="#507CD1"  Width="50px" Font-Bold="True" ForeColor="White" />
             <EditRowStyle BackColor="#2461BF" />
             <AlternatingRowStyle BackColor="White" />
             <Columns>
                 <asp:TemplateField>
                     <ItemTemplate>
                         <asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="true" QuotesKey='<%#Eval("WONumber").ToString() %>' OnCheckedChanged="chkSelect_CheckedChanged"  />
                     </ItemTemplate>
                 </asp:TemplateField>
 </Columns>


 

Hi,

 

Show us your  chkSelect_CheckedChanged method.


Protected Sub chkSelect_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim indx As Integer
        Dim connectionString As String = "Database=pjt;" & "Data Source=localhost;" & "User Id=root;Password=prasad123"
        Dim query As String = "Select WONumber,PartNumber,Rev,customer,CRep,AEng,Orderqty,PReceived,FabDue,FabComp,AssyDue,AssyComp,TestDue,TestComp,Notes,Shippedqty,status from status"
        'Dim query As String = "Select partnumber from status"
        Dim connection As New MySqlConnection(connectionString)
        Dim da As New MySqlDataAdapter(query, connection)
        Dim ds As New DataSet()        Dim myAdapter As New MySqlDataAdapter
        myAdapter = New MySqlDataAdapter(query, connection)
        myAdapter.Fill(ds, "status")
        Dim dt As DataTable = New DataTable() 'DataTable Initializes a new instance of the DataTable class with no arguments.
        da.Fill(dt)        Dim checkbox As CheckBox = CType(sender, CheckBox)
        Dim row As GridViewRow = CType(checkbox.NamingContainer, GridViewRow)
        Dim i As Integer        For i = 0 To dt.Rows.Count - 1 Step i + 1
            If (dt.Rows(i)("WONumber").ToString = row.Cells(1).Text.ToString()) Then
                indx = i            End If        Next
        txtWON.Text = dt.Rows(indx)("WONumber").ToString()
        txtPartNumber.Text = dt.Rows(indx)("PartNumber").ToString()
        txtRev.Text = dt.Rows(indx)("Rev").ToString()
        txtCust.Text = dt.Rows(indx)("Customer").ToString()
        DDCR.Text = dt.Rows(indx)("CRep").ToString()
        DDAE.Text = dt.Rows(indx)("AEng").ToString()
        txtOQty.Text = dt.Rows(indx)("OrderQty").ToString()
        DDPR.Text = dt.Rows(indx)("PReceived").ToString
        txtFDD.Text = dt.Rows(indx)("FabDue").ToString()
        txtFCD.Text = dt.Rows(indx)("FabComp").ToString()
        txtADD.Text = dt.Rows(indx)("AssyDue").ToString
        txtACD.Text = dt.Rows(indx)("AssyComp").ToString()
        txtTDD.Text = dt.Rows(indx)("TestDue").ToString()
        txtTCD.Text = dt.Rows(indx)("TestComp").ToString()
        txtDes.Text = dt.Rows(indx)("Notes").ToString()
        txtShipQty.Text = dt.Rows(indx)("ShippedQty").ToString()
        DDStatus.Text = dt.Rows(indx)("Status").ToString()    End Sub

Hi, Give your chkSelect_CheckedChanged event handler as below.

 

1. First you clear your textboxes.

2. In the loop, you uncheck previous checkboxes

3. Finally if you have checked any checkbox, then that line will have its value filled in the textboxes.

Just make sure that you are using the same query for filling the datatable and also for binding the gridview.

Hope this helps.

 

 

Protected Sub chkSelect_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        txtWON.Text = ""        txtPartNumber.Text = ""        txtRev.Text = ""
        txtCust.Text = ""        DDCR.Text = ""        DDAE.Text = ""
        txtOQty.Text = ""        DDPR.Text = ""        txtFDD.Text = ""
        txtFCD.Text = ""        txtADD.Text = ""        txtACD.Text = ""
        txtTDD.Text = ""        txtTCD.Text = ""        txtDes.Text = ""
        txtShipQty.Text = ""        DDStatus.Text = ""
        Dim indx As Integer
        Dim connectionString As String = "Database=pjt;" & "Data Source=localhost;" & "User Id=root;Password=prasad123"
        Dim query As String = "Select WONumber,PartNumber,Rev,customer,CRep,AEng,Orderqty,PReceived,FabDue,FabComp,AssyDue,AssyComp,TestDue,TestComp,Notes,Shippedqty,status from status"
        'Dim query As String = "Select partnumber from status"
        Dim connection As New MySqlConnection(connectionString)
        Dim da As New MySqlDataAdapter(query, connection)
        Dim ds As New DataSet()        Dim myAdapter As New MySqlDataAdapter
        myAdapter = New MySqlDataAdapter(query, connection)
        myAdapter.Fill(ds, "status")
        Dim dt As DataTable = New DataTable() 'DataTable Initializes a new instance of the DataTable class with no arguments.
        da.Fill(dt)        Dim checkbox As CheckBox = CType(sender, CheckBox)
        Dim row As GridViewRow = CType(checkbox.NamingContainer, GridViewRow)
        Dim i As Integer        For i = 0 To dt.Rows.Count - 1 Step i + 1
            If (dt.Rows(i)("WONumber").ToString = row.Cells(1).Text.ToString()) Then
                indx = i            Else
                Dim loopCheckBox As CheckBox = CType(GVStatus.Rows(i).Cells(0).Controls(1), CheckBox)
                loopCheckBox.Checked = False            End If        Next
        If (checkbox.Checked) Then
            txtWON.Text = dt.Rows(indx)("WONumber").ToString()
            txtPartNumber.Text = dt.Rows(indx)("PartNumber").ToString()
            txtRev.Text = dt.Rows(indx)("Rev").ToString()
            txtCust.Text = dt.Rows(indx)("Customer").ToString()
            DDCR.Text = dt.Rows(indx)("CRep").ToString()
            DDAE.Text = dt.Rows(indx)("AEng").ToString()
            txtOQty.Text = dt.Rows(indx)("OrderQty").ToString()
            DDPR.Text = dt.Rows(indx)("PReceived").ToString
            txtFDD.Text = dt.Rows(indx)("FabDue").ToString()
            txtFCD.Text = dt.Rows(indx)("FabComp").ToString()
            txtADD.Text = dt.Rows(indx)("AssyDue").ToString
            txtACD.Text = dt.Rows(indx)("AssyComp").ToString()
            txtTDD.Text = dt.Rows(indx)("TestDue").ToString()
            txtTCD.Text = dt.Rows(indx)("TestComp").ToString()
            txtDes.Text = dt.Rows(indx)("Notes").ToString()
            txtShipQty.Text = dt.Rows(indx)("ShippedQty").ToString()
            DDStatus.Text = dt.Rows(indx)("Status").ToString()        End If
    End Sub

 

Wow pretty precise solution Lateef,Thank you so much,Have a Great day.