You must Sign In to post a response.
  • Category: WPF

    Can we set grid's width in code while populating from autocomplete box

    Hi everyone,

    I need to set the width of grid whic is populating from autocomplete box..Can I do this in code through any handler..I tried in Populating event..but unable to get the grid'sproperty over there..Please help me out

    thanks
  • #757325
    Hi

    I have paste code for Autocomplete

    Step1

    Add One Webservice your project then call from your client side Autocompleted Control like this


    [WebMethod]
    public string[] AutoComp(string prefixText, int count)
    {
    List<string> lstStates = new List<string>();
    DataTable _objdt = new DataTable();
    _objdt = GetData(prefixText);
    if (_objdt.Rows.Count > 0)
    {
    for (int i = 0; i < _objdt.Rows.Count; i++)
    {
    lstStates.Add(_objdt.Rows[i]["State"].ToString());
    }
    }
    return lstStates.ToArray();
    }

    public DataTable GetData(string prefixText)
    {
    string connectionstring = "Data Source=PC-NAME;Initial Catalog=Test;Integrated Security=True;";
    DataTable _objdt = new DataTable();
    string querystring = "select * from Tblstate where State like '%" + prefixText + "%';";
    SqlConnection _objcon = new SqlConnection(connectionstring);
    SqlDataAdapter _objda = new SqlDataAdapter(querystring, _objcon);
    _objcon.Open();
    _objda.Fill(_objdt);
    return _objdt;
    }


    Step2
    Client Side

    Search : <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

    <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
    ServiceMethod="AutoComp"
    ServicePath="~/WebService2.asmx"
    MinimumPrefixLength="2"
    CompletionInterval="100"
    EnableCaching="false"
    CompletionSetCount="10"
    TargetControlID="TextBox1"
    FirstRowSelected="false">
    </asp:AutoCompleteExtender>

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


  • Sign In to post your comments