2 Replies - 819 Views - Last Post: 19 August 2008 - 02:15 AM Rate Topic: -----

#1 Goober  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 09-July 08

Regarding to databound

Posted 18 August 2008 - 03:02 AM

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.

<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>



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



Posted 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.

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...

Is This A Good Question/Topic? 0
  • +

Replies To: Regarding to databound

#2 kelvinskw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-August 08

Re: Regarding to databound

Posted 18 August 2008 - 06:55 PM

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 August 2008 - 07:02 PM

Was This Post Helpful? 0
  • +
  • -

#3 Goober  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 09-July 08

Re: Regarding to databound

Posted 19 August 2008 - 02:15 AM

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

Anyone can help ?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1