|
how to include 2 link button in datagrid and i wud like to add codings for both link button i have writtencoding for one link button but in second link button i m not able to access and for what purpose we are givin datagrid1.editindexitem=-1
if u have answer pls help me
the code is
===========
protected void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e)
{
if (e.CommandName == "lnkbt1")
{
int k = Convert.ToInt32(e.CommandArgument.ToString());
DataGrid1.EditItemIndex = -1;
con = new SqlConnection("server=SOFTWARE4;uid=sa;pwd=;database=helpdesk1");
con.Open();
string m = "select callno,blkid,locid,deptid,pblmtype,problem,allocated,allocatedby from swiftresult where callno="+k;
cmd = new SqlCommand(m, con);
loaddata();
dr = cmd.ExecuteReader();
if (dr.Read())
{
string d=DateTime.Now.ToString();
string block = (string)dr["blkid"].ToString();
string loc = (string)dr["locid"].ToString();
string dep = (string)dr["deptid"].ToString();
string pbtype = (string)dr["pblmtype"].ToString();
string problem = (string)dr["problem"].ToString();
string allocatedby = (string)dr["allocatedby"].ToString();
SqlConnection con1 = new SqlConnection("server=SOFTWARE4;uid=sa;pwd=;database=helpdesk1");
con1.Open();
string upd="update swiftresult set status='c' where allocated='"+txt_uname.Text+"' and callno="+k;
string query="insert into ituser_status(callno,blkid,locid,deptid,pblmtype,problem,completedon,completedby,allocatedby)values("+k+",'"+block+"','"+loc+"','"+dep+"','"+pbtype+"','"+problem+"','"+d+"','"+txt_uname.Text+"','"+allocatedby+"')";
SqlCommand cmd1 = new SqlCommand(query, con1);
SqlCommand cmd2 = new SqlCommand(upd, con1);
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
Response.Write(k);
loaddata();
con1.Close();
}
if (e.CommandName == "lnkbt2")
{
int x = Convert.ToInt32(e.CommandArgument.ToString());
DataGrid1.EditItemIndex = -1;
con = new SqlConnection("server=SOFTWARE4;uid=sa;pwd=;database=helpdesk1");
con.Open();
string l = "select callno,blkid,locid,deptid,pblmtype,problem,allocated,allocatedby from swiftresult where callno=" + x;
cmd = new SqlCommand(l, con);
loaddata();
dr = cmd.ExecuteReader();
if (dr.Read())
{
string upd1 = "update swiftresult set status='e' where allocated='" + txt_uname.Text + "' and callno=" + x;
SqlCommand cmd1 = new SqlCommand(upd1, con);
cmd1.ExecuteNonQuery();
Response.Write("loaded");
loaddata();
//con.Close();
}
}
dr.Close();
con.Close();
}
}
k.priya
|
|
|
|
|
priyamsc wrote: for what purpose we are givin datagrid1.editindexitem=-1
Setting EditIndexItem = -1 will turn off the Edit mode of DataGrid. The EditIndexItem = 0 will make the first row of the DataGrid editable.
priyamsc wrote: how to include 2 link button in datagrid and i wud like to add codings for both link button i have writtencoding for one link button but in second link button i m not able to access
Give proper ID for the LinkButtons. You can get the reference of the LinkButton using
dataGrid1.Items[rowIndex].Cells[columnIndex].FindControl(controlName);
May be you already knew this since this is very old post. I thought I could answer. Let me know if you have any questions.
|
|
|
|