in my web page i am having different hyperlinks for letter a to z and now i want to display all the details in gridview of the names starting with particular letter in my db table on clicking of hyperlink..

plz help its urgent..........

Dani AI

Generated

Following 's LinkButton idea and 's href concern, here are practical alternatives, gotchas and quick fixes that solve the common issues reported by .

Use-case options

  • Server postback (LinkButton/DataList or Repeater): works well and keeps logic on the server. If links are created dynamically, recreate them in Page_Init so event wiring survives postbacks. Check event handlers (ItemCommand / OnCommand) and avoid re-binding the GridView on every Page_Load (use the usual !IsPostBack guard, but still call the bind method when the letter is received).
  • Querystring anchors (<a href="?letter=A">): simplest for static lists, bookmarkable and SEO-friendly. Read Request.QueryString["letter"] in Page_Load and bind the grid. This avoids event handler issues and makes URLs shareable.
  • Partial update / AJAX: for nicer UX use an UpdatePanel or a JSON WebMethod / Web API endpoint, return results and update the table client-side without a full reload.

Security, correctness and performance notes

  • Always parameterize the query; do not concatenate user input into SQL. Example pattern:

    cmd.CommandText = "SELECT Id, Name FROM People WHERE Name LIKE @prefix";
    cmd.Parameters.AddWithValue("@prefix", prefix + "%");
  • Escaping and collation: if names contain accented characters, decide on a collation or normalize input. If users can submit characters that are SQL wildcards, escape them or use an ESCAPE clause.

  • Indexes & paging: "starts-with" searches (prefix + '%') can use an index; avoid SELECT * and enable server-side paging when the result set can be large.

  • Accessibility: use clear focus/ARIA and style the active letter. Provide an "Other" link for non A–Z starters.

Troubleshooting checklist

  • Verify the received letter (log Request.QueryString or command arg).
  • Confirm the SQL executed (SQL Profiler or logging).
  • If using dynamic controls, recreate them on every request before events fire.
  • If GridView still doesn't show data, ensure DataBind is called after setting DataSource and that ViewState handling isn't preventing display.

These steps address both the simple QueryString approach and the LinkButton event approach suggested earlier, plus the common pitfalls that cause "it works on first try, then stops" behavior.

Recommended Answers

All 4 Replies

I assume, you are using DataList control for Alphabetic heading and you have added link button for each alphabetic letter I mean A, B, C ….Z …

Now, you need to set CommandArgument or CommandName property of link button with the Alphabetic character. Then you need to handle the OnCommand event of link button.

Now create one function which will accept your clicked alphabetic as argument I mean your function may looks like :

SearchData(string strSearchWord)
{
here your sql query will go and in the where clause you need to pass argument.
i.e. “where name like ' “ + strSearchWord + “%'”

then execute the query and store data in DataTable or DataSet and bind it with your Gridview.
}

========================================================================================

in my web page i am having different hyperlinks for letter a to z and now i want to display all the details in gridview of the names starting with particular letter in my db table on clicking of hyperlink..

plz help its urgent..........

thanks............now it is working

some problem ...can u plz provide some code

in my web page i am having different hyperlinks for letter a to z and now i want to display all the details in gridview of the names starting with particular letter in my db table on clicking of hyperlink..

plz help its urgent..........

Hi deeptakshd

I am thinking Just like as You but i cannot be able to Create A to Z Hyperlinks in my code because hyperlinks demanded (href) value. but i don't want to give that or redirect to other page in asp.net

Will u send me your code of syntax to control this issue.

Thanks in Advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.