3
Contributors
21
Replies
30
Views
5 Years
Discussion Span
Last Post by mani-hellboy
0
Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim btn As Button = CType(sender, Button)
        btn.Text = (Int32.Parse(btn.Text) + 1).ToString()
    End Sub

Kindly describe the line:

(Int32.Parse(btn.Text) + 1).ToString()

Edited by peter_budo: Keep It Clear - Do use code tags when posting any code

0

Hi,

btn.Text returns a string even if you have an integer value in the button. So if you want to add one to that string, then you have to first convert the text to an integer. To convert a string to integer, you can use int32.Parse(). Once you get the integer, you add 1 and then convert this integer back to string using .ToString() method.

Edited by binoy.mathew: make it more clear

0

I cant get this why would we add 1 to this string by converting it into integer??? Plz explain...

0

have you tried clicking the button for which the code is written. See what is the result. I dont know under what context you have this code.. I am making some assumptions..Assumptions are,
1. you have a button on the form
2. the button has some integer as its text, may be 1, 2, 3 or whatever
3. When you click on the button, the buttons text should increase by one. so if you have 1 as buttons text then the button text should become 2 and again if you click it and then 3 and so on..

Hope this explains

0

Please see the above two images....
What code should i enter so that i could exit the form after clicking the button???
I am using C sharp..
Or is it possible to exit the browser when i click this exit button???

0

Guys got the Solution for this ...
We can close our form by including the following code :

btnexit.Attributes.Add("onclick", "window.close()");

Where btnexit is the name of my button...

0

My next question is how can i write a code for deleting a row using gridview

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridViewRow row = GridView1.Rows[e.RowIndex];

         objCust.CustId = Convert.ToInt32(objCust.findCustId().Tables[0].Rows[0][0].ToString());

        objCust.DeleteNewUser();

        if (objCust.DeleteNewUser() == 1)
        {
            bindGvEdit();
        }
    }

But I am getting a error as

CS0019: Operator '==' cannot be applied to operands of type 'System.Data.DataSet' and 'int'

Plz suggest how to rectify...

0

I have written stored procedure for DeleteNewUser in Sql server 2005... I am using visual studio 2005 as well..

0

Actually Guys the problem was with the Bll; Which would look like:

public int DeleteNewUser()
    {
    DBAccess db = new DBAccess();
    db.AddParameter("@iCustId", iCustId);
    return db.ExecuteNonQuery("[tblCust_Delete]",true);
    }

and the modified code would be:

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
     
    GridViewRow row = GridView1.Rows[e.RowIndex];
     
    objCust.CustId = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
     
    if (objCust.DeleteNewUser() > 0)
    {
    bindGvEdit();
    }
    }

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

Guys I am marking this thread as Unsolved bcoz i want to make this thread a Discussion spot for all beginners like me who want to learn this language..
This thread is within top ten in google search list:
So I dont want to wrap it up lyk that...
Contributors plz contribute... Any question related to ASP.net and SQL SERVER is welcomed...

Regards,

Vishal Ranjan

0

I will be putting links to most useful study material for learning ASP.NET..

Guys plz make a note of it......

http://www.dotnetspider.com/AspNet-Tutorial-44.aspx ----- Dot Net Projects

http://www.w3schools.com/ ---- a very good website 4 learning many web-based languages

http://www.aspspider.com/tutorials/ --- Very good website for learning

http://webdesign.about.com/

http://www.sourcecodeonline.com/sources/asp_net.html -- Source codes for various asp.net appln

http://www.codeproject.com/ -- another website for source code related article

0

I am having a doubt:
Consider the following code...

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow row = GridView1.Rows[e.RowIndex];
        objCust.CustId = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
        objCust.CustAddress = ((TextBox)row.Cells[2].Controls[0]).Text;
        objCust.UpdateNewUser();
        GridView1.EditIndex = -1;
        bindGvEdit();
    }

What does '0' in Controls[0] stands for???

-1

Since There is only one control in for the cell(In my case the cell is CustAddress represented by Cells[2] where 2 is the number of the cell)..
So in here we are using only one control that is TextBox in my case...
So we are putting 0 over here...

-2

hey dude that will be error because you can`t able to convert (or parse) string in to number because default button name button<count>

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.