Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 28th, 2008, 07:31 AM
Registered User
 
Join Date: Jul 2007
Location: sankaran kovil, tamil nadu, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to select the particular record?

  hi i am doing search window .here i am using callback method . depending upon what ever value we entering in
text box i getting value at keyup evevnt and fetching record and showing that record in gridview.
now my question is how to select the particular record from gridview . for this i given
grvProducts.AutoGenerateSelectButton = true , that select button is coming but link is not there

Mycode :
   aspx :

  <table width ="50%" >
        <tr>
         <td><b>Search On</b></td><td align ="left" >
                    <asp:DropDownList ID="drp_customer" runat="server">
                        <asp:ListItem Value="c_code">Code</asp:ListItem>
                        <asp:ListItem Value="c_name">Name</asp:ListItem>
                        <asp:ListItem Value="c_add1">Add1</asp:ListItem>
                        <asp:ListItem Value="c_add2">Add2</asp:ListItem>
                        <asp:ListItem Value="c_add3">Add3</asp:ListItem>
                        <asp:ListItem Value="c_city">City</asp:ListItem>
                        <asp:ListItem Value="c_area_code">Areacode</asp:ListItem>
                    </asp:DropDownList>
                    </td>
                    </tr>
                <tr>
                <td><b>Enter the Text</b></td><td align ="left">
                    <asp:TextBox ID="TextBox1" runat="server" onkeyup ="CallSrv(this);"></asp:TextBox></td></tr>
                    <tr>
                    <td colspan = "2">
                    <div id="grvProducts"> </div>
           </td></tr></table>

Aspx.cs:


    string RenderedOutput;
    protected void Page_Load(object sender, EventArgs e)
    {
        ClientScriptManager scriptMgr = Page.ClientScript;
        String cbReference = scriptMgr.GetCallbackEventReference(this, "arg","ReceiveServerData", "");
        String callbackScript = "function CallServer(arg, context) {" + cbReference + "; }";
        scriptMgr.RegisterClientScriptBlock(this.GetType() , "CallServer", callbackScript, true);

    }

    public void RaiseCallbackEvent(string eventArgument)
    {
        string[] commands = eventArgument.Split(",".ToCharArray());
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM customer where " + commands[0] + " like '" + commands [1] + "%' ", "SERVER=(local);DATABASE=ramag;TRUSTED_CONNECTION= true;");
        DataTable table = new DataTable();
        adapter.Fill(table);

            GridView grvProducts = new GridView();
            grvProducts.AutoGenerateSelectButton = true;
            grvProducts.DataSource = table ;
            grvProducts.DataBind();
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            System.IO.StringWriter sw = new System.IO.StringWriter(sb);
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            grvProducts.RenderControl(htw);
            this.RenderedOutput = sb.ToString();

    }

    public string GetCallbackResult()
    {
        return RenderedOutput;
    }
  #2 (permalink)  
Old August 8th, 2008, 05:55 AM
Authorized User
 
Join Date: Jul 2008
Location: Cape Town, Western Cape, South Africa.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by azymd777
  hi i am doing search window .here i am using callback method . depending upon what ever value we entering in
text box i getting value at keyup evevnt and fetching record and showing that record in gridview.
now my question is how to select the particular record from gridview . for this i given
grvProducts.AutoGenerateSelectButton = true , that select button is coming but link is not there

Mycode :
aspx :

<table width ="50%" >
        <tr>
         <td><b>Search On</b></td><td align ="left" >
                    <asp:DropDownList ID="drp_customer" runat="server">
                        <asp:ListItem Value="c_code">Code</asp:ListItem>
                        <asp:ListItem Value="c_name">Name</asp:ListItem>
                        <asp:ListItem Value="c_add1">Add1</asp:ListItem>
                        <asp:ListItem Value="c_add2">Add2</asp:ListItem>
                        <asp:ListItem Value="c_add3">Add3</asp:ListItem>
                        <asp:ListItem Value="c_city">City</asp:ListItem>
                        <asp:ListItem Value="c_area_code">Areacode</asp:ListItem>
                    </asp:DropDownList>
                    </td>
                    </tr>
                <tr>
                <td><b>Enter the Text</b></td><td align ="left">
                    <asp:TextBox ID="TextBox1" runat="server" onkeyup ="CallSrv(this);"></asp:TextBox></td></tr>
                    <tr>
                    <td colspan = "2">
                    <div id="grvProducts"> </div>
         </td></tr></table>

Aspx.cs:


    string RenderedOutput;
    protected void Page_Load(object sender, EventArgs e)
    {
        ClientScriptManager scriptMgr = Page.ClientScript;
        String cbReference = scriptMgr.GetCallbackEventReference(this, "arg","ReceiveServerData", "");
        String callbackScript = "function CallServer(arg, context) {" + cbReference + "; }";
        scriptMgr.RegisterClientScriptBlock(this.GetType() , "CallServer", callbackScript, true);

    }

    public void RaiseCallbackEvent(string eventArgument)
    {
        string[] commands = eventArgument.Split(",".ToCharArray());
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM customer where " + commands[0] + " like '" + commands [1] + "%' ", "SERVER=(local);DATABASE=ramag;TRUSTED_CONNECTION= true;");
        DataTable table = new DataTable();
        adapter.Fill(table);

            GridView grvProducts = new GridView();
            grvProducts.AutoGenerateSelectButton = true;
            grvProducts.DataSource = table ;
            grvProducts.DataBind();
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            System.IO.StringWriter sw = new System.IO.StringWriter(sb);
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            grvProducts.RenderControl(htw);
            this.RenderedOutput = sb.ToString();

    }

    public string GetCallbackResult()
    {
        return RenderedOutput;
    }

Hi there.

i am a student in cape town south africa. i'm interested in your code of populating a fields with a textbox also specifying a criteria.

supertedz


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select two MAX record per each veeruu SQL Language 2 January 23rd, 2006 12:57 AM
SELECT every fourth record rylemer Access 1 September 1st, 2004 05:06 AM
Select record after inserting it whyulil Classic ASP Databases 13 April 26th, 2004 06:05 AM
select last few record..... pls help life_s Ng ASP.NET 1.0 and 1.1 Basics 4 October 1st, 2003 01:36 AM
How to search for (and select) a record? Haroldd Access 2 June 30th, 2003 06:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.