Hi,
  I receive a mail regarding how to transfer textbox value to datagrid when we 
press button. But mistake that mail is deleted from my mailbox.
 
Here I attach text file that contain code for that. AnyOne who use this come 
give feedback to me that is this code is helpful for him/ her
 
thanks 
 
Krishan Kant


Send instant messages to your online friends http://uk.messenger.yahoo.com 
  ----------

This Program Add User Name in DataGrid When User press a command button.        

Place these control on webform:
1) TextBox Control
2) One Button 
3) DataGrid In my Webform.: Create One Bound Column and set its datafield 
property to "NAME".
4) Now Write following code in Page Load and Button_Click Event.


                // Variable Declaration Goes Here.
                protected DataSet ds;

                private void Page_Load(object sender, System.EventArgs e)
                {
                        if (!IsPostBack)
                        {
                                ds =new DataSet();
                                ds.Tables.Add();
                                ds.Tables[0].Columns.Add( "NAME", 
Type.GetType("System.String"));
                                ViewState["ds"]=ds;
                        }

                        if (ViewState["ds"]!=null)
                        {
                                ds=(DataSet) ViewState["ds"]; 
                        }
                }




                private void Button1_Click(object sender, System.EventArgs e)
                {       
                        try
                        {
                                DataRow Dr = ds.Tables[0].NewRow();
                                Dr["NAME"] = TextBox1.Text;
                                // Add row to dataset
                                ds.Tables[0].Rows.Add(Dr);


                                dgGrid.DataSource=ds.Tables[0];
                                dgGrid.DataBind();

                                ViewState["ds"]=ds;

                        }
                        catch(Exception Err)
                        {
                                Response.Write(Err.Message);
                        }
                }

[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to