Click here to Skip to main content
15,909,205 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: parent and pop up window records Pin
Christian Graus21-Feb-08 9:22
protectorChristian Graus21-Feb-08 9:22 
Generaldatarelation Pin
niki_nilu21-Feb-08 1:54
niki_nilu21-Feb-08 1:54 
GeneralRe: datarelation Pin
Not Active21-Feb-08 2:27
mentorNot Active21-Feb-08 2:27 
GeneralRe: datarelation Pin
niki_nilu21-Feb-08 3:16
niki_nilu21-Feb-08 3:16 
GeneralRe: datarelation Pin
Not Active21-Feb-08 3:46
mentorNot Active21-Feb-08 3:46 
GeneralRe: datarelation Pin
niki_nilu21-Feb-08 20:25
niki_nilu21-Feb-08 20:25 
GeneralRe: datarelation Pin
Not Active22-Feb-08 2:25
mentorNot Active22-Feb-08 2:25 
QuestionUpload files from client machine to server Pin
MayyMagdy21-Feb-08 0:46
MayyMagdy21-Feb-08 0:46 
GeneralRe: Upload files from client machine to server Pin
hartertobak21-Feb-08 9:27
hartertobak21-Feb-08 9:27 
GeneralPlz help me abt login controls [modified] Pin
Member 387988121-Feb-08 0:10
Member 387988121-Feb-08 0:10 
QuestionProblem with Sessions Pin
kolag21-Feb-08 0:10
kolag21-Feb-08 0:10 
QuestionNew Features in 3.5 [modified] Pin
Kuricheti20-Feb-08 23:42
Kuricheti20-Feb-08 23:42 
GeneralRe: New Features in 3.5 Pin
Not Active21-Feb-08 2:18
mentorNot Active21-Feb-08 2:18 
GeneralRe: New Features in 3.5 Pin
Kuricheti21-Feb-08 4:51
Kuricheti21-Feb-08 4:51 
GeneralRe: New Features in 3.5 Pin
Not Active21-Feb-08 5:13
mentorNot Active21-Feb-08 5:13 
QuestionDataGrid Property Builder ??? Pin
John Sundar20-Feb-08 23:28
John Sundar20-Feb-08 23:28 
Questionleft trim Pin
Sonia Gupta20-Feb-08 23:18
Sonia Gupta20-Feb-08 23:18 
GeneralConfiguration error Pin
Member 387988120-Feb-08 22:55
Member 387988120-Feb-08 22:55 
GeneralThread: GridView isn't showing up Pin
Albert8320-Feb-08 21:43
Albert8320-Feb-08 21:43 
I am trying to bind a grid in when the user click on a button. What should happen in the button is this:
I have to txt boxes - last name, first name.
When the user clicks on the button, it should look up the last name entered in the txt box, retrieve the records if there are, and bind to the grid view. However, the results are not showing in grid at all. I created a test label which does show the values entered in the boxes. Here is the code. Thanks for reading and help.

cs code:

protected void btnFind_Click(object sender, EventArgs e)
{
string firstName = (string)txtFirstName.Text;
string lastName = (string)txtLastName.Text;

using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM users_info WHERE last_name = @last_name", conn);
cmd.Parameters.Add(new SqlParameter("@last_name", lNAme));
SqlDataReader dr = cmd.ExecuteReader();

int rowsRetrieved = 0;

while (dr.Read())
{
Label1.Text = "The value is " + dr["last_name"] + dr["first_name"];

rowsRetrieved++;
}
if (rowsRetrieved >= 1)
{
GridView1.DataSource = dr;
GridView1.DataBind();
GridView1.Visible = true;
}

Console.WriteLine("{0} row(s) retrieved", rowsRetrieved);
dr.Close();
conn.Close();
}

aspx file:

<asp:Button ID="btnFind" runat="server" Text="find" OnClick="btnFind_Click" /></td>

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="first_name" HeaderText="First Name" SortExpression="first_name" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="last_name" HeaderText="Last Name" SortExpression="last_name" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>

</asp:GridView>
Generalhtml table sort and scroll with fixed header Pin
venky45620-Feb-08 21:01
venky45620-Feb-08 21:01 
GeneralRe: html table sort and scroll with fixed header Pin
Christian Graus20-Feb-08 21:09
protectorChristian Graus20-Feb-08 21:09 
QuestionSQL Pin
senthilsstil20-Feb-08 21:00
senthilsstil20-Feb-08 21:00 
GeneralRe: SQL Pin
Christian Graus20-Feb-08 21:06
protectorChristian Graus20-Feb-08 21:06 
GeneralVallidation Expression for string values Pin
SreejithAchutan20-Feb-08 20:51
SreejithAchutan20-Feb-08 20:51 
GeneralRe: Vallidation Expression for string values Pin
Christian Graus20-Feb-08 22:17
protectorChristian Graus20-Feb-08 22:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.