Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,415 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,410 people online right now. Registration is fast and FREE... Join Now!




Regarding to databound

 
Reply to this topicStart new topic

Regarding to databound

Goober
18 Aug, 2008 - 02:02 AM
Post #1

New D.I.C Head
*

Joined: 9 Jul, 2008
Posts: 7

Hi...Im trying to code a page, when the user click on edit button on data grid, they will able to change the data inside the column. As the picture show, how can i unable the Link column, since the user just allow to modify description column only.

CODE

<Columns>
                    <asp:BoundField DataField="link" HeaderText="Link" SortExpression="link"/>
                    
                    <asp:TemplateField HeaderText="Description">
                    <ItemTemplate>
                    <asp:TextBox ID="txtlinkdetail" Runat="Server" Text='<%# DataBinder.Eval(Container, "DataItem.linkdetail") %>'/>
                     </ItemTemplate>
                     <EditItemTemplate>
                     <asp:TextBox ID="txtEditlinkdetail" Runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.linkdetail") %>'></asp:TextBox>
                    </EditItemTemplate>
                    </asp:TemplateField>


CODE
protected void GridView1_Edit(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
            GridView1.DataBind();
        }


IPB Image

Another thing , my program will call 2 times of the update function. When it run 2 times of the function, the dec is null... so when finish execute the page. There is null value of desc on database table.

CODE

protected void GridView1_Updating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                DataKey getData = GridView1.DataKeys[e.RowIndex];
                Session["link"] = getData["link"].ToString();
                string link = Session["link"].ToString();

                TextBox txtEditlinkdetail = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtEditlinkdetail");
                string desc = txtEditlinkdetail.Text.Trim();

AdminDA agent = new AdminDA();
                 if (agent.UpdateBulkDesc(link, desc) != false)
                   {
                     string message = "Description has been updated successfully.";
                     ShowMessageBox(message);
}

DA:
public bool UpdateBulkDesc(string link, string desc) //Bulk Link
        {
            bool ret;

            try
            {
                Database db = DatabaseFactory.CreateDatabase("BulkSMS");

                string strSql = "update Bulk_link set linkdetail = '" + desc + "' where link = '" + link + "'";
ret = true;
             }
}


Help Plz...


User is offlineProfile CardPM
+Quote Post

kelvinskw
RE: Regarding To Databound
18 Aug, 2008 - 05:55 PM
Post #2

New D.I.C Head
*

Joined: 18 Aug, 2008
Posts: 1

U shall not do ur update in :

protected void GridView1_Updating(object sender, GridViewUpdateEventArgs e)

this function mainly is use for validation before u doing the update... Mayb u can try to do the update in update_Command if it is a datagrid.

This post has been edited by kelvinskw: 18 Aug, 2008 - 06:02 PM
User is offlineProfile CardPM
+Quote Post

Goober
RE: Regarding To Databound
19 Aug, 2008 - 01:15 AM
Post #3

New D.I.C Head
*

Joined: 9 Jul, 2008
Posts: 7

Hi... I found another problem as the picture attached as below:
IPB Image

Anyone can help ?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:44PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month